如何覆盖 readthedocs 上的模板?
How do I override a template on readthedocs?
我最近将 sphinx documentation for blowdrycss 添加到 readthedocs。
我想覆盖 readthedocs 上的 layout.html 模板。我当前的模板覆盖在 localhost
上运行良好,但在 readthedocs 上运行不佳。该项目使用扩展基本主题的 Alabaster 主题。
项目目录结构可见here
相关部分为:
blowdrycss/
docs/
_templates/
layout.html
conf.py
conf.py
中的模板设置:
templates_path = ['_templates']
layout.html的内容:
{% extends '!layout.html' %}
{% block sidebarsearch %}
{{ super() }}
<a href="https://flattr.com/submit/auto?user_id=nueverest&url=https%3A%2F%2Fgithub.com%2Fnueverest%2Fblowdrycss" target="_blank"><img src="http://button.flattr.com/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
{% endblock %}
{% block footer %}
<div class="footer" style="text-align: center;">
<a href="https://flattr.com/submit/auto?user_id=nueverest&url=https%3A%2F%2Fgithub.com%2Fnueverest%2Fblowdrycss" target="_blank"><img src="http://button.flattr.com/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
</div>
{{ super() }}
{% endblock %}
如何覆盖 readthedocs 上的 layout.html
模板?
更新
我也试过:
相关部分为:
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
conf.py
中的模板设置:
templates_path = ['custom_templates']
虽然 readthedocs 不直接支持 templates_path
,但您可以使用带有模板的自定义主题。 http://sphinx-doc.org/theming.html
只需创建一个新的主题目录并将其添加到您的 conf.py
:
html_theme = 'your_theme'
html_theme_path = ['.']
你可以在我的一个项目中看到一个例子:
看起来现在 ReadTheDocs 应该 支持 templates_path
: https://docs.readthedocs.io/en/stable/guides/remove-edit-buttons.html?highlight=templates_path#remove-links-from-top-right-corner
我最近将 sphinx documentation for blowdrycss 添加到 readthedocs。
我想覆盖 readthedocs 上的 layout.html 模板。我当前的模板覆盖在 localhost
上运行良好,但在 readthedocs 上运行不佳。该项目使用扩展基本主题的 Alabaster 主题。
项目目录结构可见here
相关部分为:
blowdrycss/
docs/
_templates/
layout.html
conf.py
conf.py
中的模板设置:
templates_path = ['_templates']
layout.html的内容:
{% extends '!layout.html' %}
{% block sidebarsearch %}
{{ super() }}
<a href="https://flattr.com/submit/auto?user_id=nueverest&url=https%3A%2F%2Fgithub.com%2Fnueverest%2Fblowdrycss" target="_blank"><img src="http://button.flattr.com/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
{% endblock %}
{% block footer %}
<div class="footer" style="text-align: center;">
<a href="https://flattr.com/submit/auto?user_id=nueverest&url=https%3A%2F%2Fgithub.com%2Fnueverest%2Fblowdrycss" target="_blank"><img src="http://button.flattr.com/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
</div>
{{ super() }}
{% endblock %}
如何覆盖 readthedocs 上的 layout.html
模板?
更新 我也试过:
相关部分为:
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
conf.py
中的模板设置:
templates_path = ['custom_templates']
虽然 readthedocs 不直接支持 templates_path
,但您可以使用带有模板的自定义主题。 http://sphinx-doc.org/theming.html
只需创建一个新的主题目录并将其添加到您的 conf.py
:
html_theme = 'your_theme'
html_theme_path = ['.']
你可以在我的一个项目中看到一个例子:
看起来现在 ReadTheDocs 应该 支持 templates_path
: https://docs.readthedocs.io/en/stable/guides/remove-edit-buttons.html?highlight=templates_path#remove-links-from-top-right-corner