user3521099
user3521099

Reputation:

How to get path of current html?

I going through various variables listed on the Templating page of sphinx. But I am not able to get the path of current html (inside the template (_template/layout.html)).

Closest I got was using rellinks. Problem is that it gives the paths of next and previous pages but not the current page.

Similarly,

{{ file }} gives ./.html
{{ pathto(pagename) }} gives ./build/html

I want the entire paths of an html file. eg. ./build/html/2017/10/12/somepage.html

How can I get it?

Upvotes: 1

Views: 1354

Answers (1)

Timotheus.Kampik
Timotheus.Kampik

Reputation: 2505

pagename will give you the path to the current file disregarding the file ending, relative to the root document of your Sphinx project. You don't need to wrap it into pathto().

For example, if the current document is located at /something/somepage.html in the root directory,{{ pagename }} returns something/somepage.

To retrieve the actual path, use something like:

/{{ pagename }}.html

or:

{{ '/' + pagename + '.html'}}.

Upvotes: 2

Related Questions