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

问题描述 投票:24回答:1

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

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

谢谢!

linux unix makefile restructuredtext python-sphinx
1个回答
31
投票

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

{% extends '!layout.html' %}

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

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

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

有关模板的更多信息,请参见:https://www.sphinx-doc.org/en/master/templating.html

© www.soinside.com 2019 - 2024. All rights reserved.