0

I'm building documentation with Sphinx and rST. The docs are internationalized and deployed to paths like this:

website.tld/en/index.html
website.tld/de/index.html

Now on each page I'd like to give a link to the same page in different languages. Current language is available as the language variable, and the list of all languages is explicitly added to the html_context and, thus, also available.

What I struggle with is the relative path to each document. Say, there's a source document at ./source/somepath/docname.rst. It builds into these:

website.tld/en/somepath/docname.html
website.tld/de/somepath/docname.html

In the Jinja2 template, how do I get the "somepath/docname.html" value?

Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67

1 Answers1

0

Suddenly, I've found the solution in an answer to a related question:

{{ pagename }}

For a source document at ./source/somepath/docname.rst, the value of pagename is "somepath/docname", which is quite what I need.

Here's the documentation for this variable.

lcnittl
  • 233
  • 1
  • 14
Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67