如何在Sphinx文档中添加自定义页脚? (reStructuredText的)

时间:2022-06-29 08:27:31

If I have some documentation, like for example Galleria's documentation, how can I set it up so that when I run the make html command it will add a custom footer on to each page?

如果我有一些文档,例如Galleria的文档,我该如何设置它以便在运行make html命令时它会在每个页面上添加一个自定义页脚?

I saw that I could potentially use the latex preamble section of conf.py if I was outputting it to a pdf format.

我看到如果我将它输出为pdf格式,我可能会使用conf.py的latex preamble部分。

Thanks!

谢谢!

1 个解决方案

#1


25  

You have to extend the default layout by providing an html file like this:

您必须通过提供如下的html文件来扩展默认布局:

{% extends '!layout.html' %}

{% block footer %}
        <!-- your html code here -->
{% endblock %}

Save this in a _templates/ subdirectory as layout.html and make sure to tell conf.py where to find this directory:

将其保存在_templates /子目录中作为layout.html,并确保告诉conf.py在哪里可以找到此目录:

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

More information on templating can be found here: http://sphinx.pocoo.org/templating.html

有关模板的更多信息,请访问:http://sphinx.pocoo.org/templating.html

#1


25  

You have to extend the default layout by providing an html file like this:

您必须通过提供如下的html文件来扩展默认布局:

{% extends '!layout.html' %}

{% block footer %}
        <!-- your html code here -->
{% endblock %}

Save this in a _templates/ subdirectory as layout.html and make sure to tell conf.py where to find this directory:

将其保存在_templates /子目录中作为layout.html,并确保告诉conf.py在哪里可以找到此目录:

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

More information on templating can be found here: http://sphinx.pocoo.org/templating.html

有关模板的更多信息,请访问:http://sphinx.pocoo.org/templating.html