You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为本地Sphinx的sphinx_rtd_theme添加额外页脚的技术问题

Hey there, let's get that custom footer up and running for your Sphinx docs using sphinx_rtd_theme. I notice a small issue in your template code that's probably causing problems—let's fix that first, then cover the rest of the setup to make sure everything works smoothly.

First, update your source/_templates/footer.html file. The key mistake here is using {{super}} instead of {{super()}}—in Jinja2, super is a function that needs to be called to pull in the original footer content. Here's the corrected version:

{% extends '!footer.html' %}
{% block extrafooter %}
    {{ super() }}
    <!-- Your custom footer content goes here -->
    <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
        <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
    </a><br />
    <!-- Add the rest of your custom footer text below -->
{% endblock %}

Next, double-check your conf.py file to ensure Sphinx knows where to find your custom templates. Add or confirm this line exists:

templates_path = ['_templates']

This line tells Sphinx to look in the source/_templates directory for any custom template overrides—without it, Sphinx might ignore your footer.html file entirely.

Quick breakdown of how this works:

  • Extending !footer.html (with the exclamation mark) tells Sphinx to inherit the original footer template from the sphinx_rtd_theme, not a local one with the same name.
  • The extrafooter block is a built-in hook in the rtd theme specifically for adding extra content to the footer—perfect for your use case.
  • Calling super() ensures the default footer content (like copyright notices and theme credits) stays intact, while your custom content gets appended right after it.

Once you've made these changes, rebuild your documentation using:

make html

Open the generated HTML files in your browser, and you should see your custom footer section sitting below the default one.

内容的提问来源于stack exchange,提问作者Jonathan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:14:26