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

如何移除RTD主题构建文档页脚的默认归属声明?

移除Read the Docs主题页脚默认归因声明

RTD主题没有提供直接关闭该声明的配置项,但可以通过以下两种方法移除:

方法1:自定义页脚模板

  • 在Sphinx项目的_templates目录(无则新建)中创建footer.html文件
  • 复制RTD主题原footer模板内容,删除包含Built with Sphinx using a theme provided by Read the Docs.的对应代码块
  • 核心模板示例(可根据主题版本微调):
<footer>
  {%- block content %}
  <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
    {%- if next %}
    <a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n" rel="next">{{ _('Next') }} <span class="fa fa-arrow-circle-right"></span></a>
    {%- endif %}
    {%- if prev %}
    <a href="{{ prev.link|e }}" class="btn btn-neutral float-left" title="{{ prev.title|striptags|e }}" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> {{ _('Previous') }}</a>
    {%- endif %}
  </div>

  <hr/>

  {%- block extrafooter %} {% endblock %}
  {%- if show_copyright %}
    {%- if hasdoc('copyright') %}
      {% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
    {%- else %}
      {% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
    {%- endif %}
  {%- endif %}
  {%- if last_updated %}
    {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
  {%- endif %}
  <!-- 移除下面的Sphinx/RTD归因块 -->
  {%- comment %}
  {%- if theme_show_sphinx %}
    {% trans %}Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.{% endtrans %}
  {%- endif %}
  {%- endcomment %}
  {%- endblock %}
</footer>
  • 保存后重新构建文档,默认声明即可消失

方法2:用CSS隐藏声明

  • 在项目中创建_static/custom.css文件
  • 在conf.py里添加配置:html_css_files = ['custom.css']
  • 在custom.css中写入:
/* 隐藏页脚的RTD归因文本 */
.rst-footer-buttons + hr + p:last-child {
    display: none;
}
  • 重新构建文档,目标文本会被隐藏

注意:因RTD主题基于MIT许可证,需确保你已在项目统一归因文档中保留合法引用,符合许可证要求。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 14:45:39