Python 如何覆盖readthedocs上的模板?
我最近加入了readthedocs 我想覆盖上的layout.html模板。我当前的模板覆盖在Python 如何覆盖readthedocs上的模板?,python,jinja2,python-sphinx,read-the-docs,Python,Jinja2,Python Sphinx,Read The Docs,我最近加入了readthedocs 我想覆盖上的layout.html模板。我当前的模板覆盖在localhost上运行良好,但在readthedocs上不起作用。该项目使用雪花石膏主题,扩展了基本主题 可以看到项目目录结构 相关部分为: blowdrycss/ docs/ _templates/ layout.html conf.py templates_path = ['_templates'] {% extends '!l
localhost
上运行良好,但在readthedocs上不起作用。该项目使用雪花石膏主题,扩展了基本主题
可以看到项目目录结构
相关部分为:
blowdrycss/
docs/
_templates/
layout.html
conf.py
templates_path = ['_templates']
{% 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 %}
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
templates_path = ['custom_templates']
conf.py中的模板设置
:
blowdrycss/
docs/
_templates/
layout.html
conf.py
templates_path = ['_templates']
{% 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 %}
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
templates_path = ['custom_templates']
layout.html的内容:
blowdrycss/
docs/
_templates/
layout.html
conf.py
templates_path = ['_templates']
{% 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 %}
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
templates_path = ['custom_templates']
conf.py中的模板设置
:
blowdrycss/
docs/
_templates/
layout.html
conf.py
templates_path = ['_templates']
{% 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 %}
blowdrycss/
docs/
custom_templates/
layout.html
conf.py
templates_path = ['custom_templates']
虽然readthedocs不直接支持
模板\u路径
,但您可以使用带有模板的自定义主题
只需创建一个新的主题目录并将其添加到conf.py
:
html_theme = 'your_theme'
html_theme_path = ['.']
您可以在我的一个项目中看到一个示例:
模板\u路径:\u模板是默认的,你能试试另一个吗?我创建了一个新的目录自定义模板
,并且将布局.html
放在readthedocs中仍然无法识别它。它实际上是在readthedocs@Wolph中记录的。我使用的是雪花石膏主题,而不是rtd主题。@Nu珠峰:我指的是这一点:“默认情况下,读取文档将使用自己的自定义sphinx主题,除非您自己在conf.py
文件中设置了一个。”
复制并粘贴了雪花石膏主题,将其重命名为自定义雪花石膏
,并编辑了模板文件。感谢您为我指明了正确的方向。