templates - 如何向 Sphinx 文档添加自定义页脚?

标签 templates python-sphinx footer

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

我发现我可以使用 the LaTeX preamble conf.py 部分(如果我将其输出为 PDF 格式)。

最佳答案

您必须通过提供如下 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

关于templates - 如何向 Sphinx 文档添加自定义页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5585250/

相关文章:

c++ - LNK2019 (VS 2008) 使用模板函数指针完整实现模板函数

php - 如何在不渲染 Twig 模板的情况下分析它们?

python-sphinx - 格式化 sphinx 表格单元格中的文本

python-sphinx - Sphinx Doc - 在为 HTML 构建时如何渲染动画 GIF,而在为 latexpdf 构建时如何渲染 PNG?

html - 如何让我的页脚在 CSS 中保持在页面底部而不重叠

c++ - 为什么必须在哪里放置 “template”和 “typename”关键字?

c++ - 为什么我不能在 C++11 中使用 constexpr 指针作为模板参数?

python - Python-Sphinx 中的多级 Toctree

html - Wordpress:页脚下方的额外空间

css - 包含多个 div 的粘性页脚不起作用