gpt4 book ai didi

html - sphinx-rtd-theme 中自定义页脚的问题

转载 作者:行者123 更新时间:2023-12-05 09:05:40 25 4
gpt4 key购买 nike

我在向我的 Sphinx .html 文件添加自定义页脚时遇到了一些问题。我正在使用 sphinx_rtd_theme。我检查过这个 post并尝试过(以及评论中的一些建议)但无济于事。我不确定我错过了什么。抱歉,如果我没有在此处发布足够的内容来实际指出导致问题的原因。感谢您提供任何帮助或建议!

我的 css 主题文件已被我自己修改(很差)(我不是 HTML/CSS 人!)但我认为这不重要吗?我唯一能想到的另一件事是,当我重新编译输出文件时,我可能必须做一些特别的事情。我只是使用:

make clean html && make html

我的 conf.py 位于:root/source/conf.py。以下是我的 conf.py 文件的一些摘录:

import sphinx_rtd_theme

project = 'Project Name'
copyright = '2021, My Company'
author = 'My Name, Coworker Name'
master_doc = 'Home'
extensions = ["sphinx_rtd_theme", "sphinx.ext.todo"]
todo_include_todos = True
templates_path = ['_templates']
source_suffix = ['.rst']
html4_writer = True
html_theme = 'sphinx_rtd_theme'
# html_theme_path = ['_static']
html_static_path = ['_static']
# html_extra_path = []
html_show_sphinx = True
html_show_copyright = True
html_style = 'css/my_theme.css'

这是我覆盖的 layout.html 文件。它位于评论中显示的路径中。

 <!-- layout.html
* Place this file in root/source/_templates
* -->
{% extends "!layout.html" %}
{% block extrahead %}
{{super}}
<link href="{{ pathto("_static/my_theme.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}

{% block extrafooter %}
{{super}}
<div class="footer">
My custom footer just needs to add a single sentance to the existing footer.
</div>
{% endblock %}

最佳答案

您想添加自定义页脚还是替换默认页脚?在我的例子中,我只需要覆盖 footer.html 文件而不是 layout.html。

这是我 100% 为我的 Sphinx 文档所做的工作:

  1. 在您的 Sphinx 元素的 _template 文件夹中创建一个 footer.html
  2. 然后添加:
{% extends "!footer.html" %}
{%- block contentinfo %}
{{ super }}
<!-- your custom footer here-->
{% endblock %}

请注意您的页脚实际包含在哪个 block 中。就我而言,它位于 contentinfo

关于html - sphinx-rtd-theme 中自定义页脚的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66919550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com