如何移除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 %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %} {%- else %} {% trans copyright=copyright|e %}© 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
相关产品推荐
相关产品推荐

