Does Jinja2 support template-relative paths e.g. %(here)s/other/template.html, to include other templates relative to the current template’s place in the filesystem?
Does Jinja2 support template-relative paths e.g. %(here)s/other/template.html , to include other templates relative to
Share
I do not believe so. Typically you include or extend other templates by specifying their paths relative to the root of whatever template loader and environment you’re using.
So let’s say your templates are all in
/path/to/templatesand you’ve set up Jinja like so:Now, if you’d like to include
/path/to/templates/includes/sidebar.htmlin the/path/to/templates/index.htmltemplate, you’d write the following in yourindex.html:and Jinja would figure out how to find it.