默认情况下,似乎使用长划线'--'作为页面标题和整个网站html_title之间的分隔符,这是在www.example.com文件中设置config.py的。我们想将其更改为"|'字符。我可以在layout.html模板中添加一个块来修改标题,我只是不确定该写什么。我希望它是'page_title| html_title'的标题标签。
iq3niunx1#
长破折号(—)来自layout.html模板:
—
{%- if not embedded and docstitle %} {%- set titlesuffix = " — "|safe + docstitle|e %} {%- else %} {%- set titlesuffix = "" %} {%- endif %}
titlesuffix的值在模板中稍靠后的位置使用:
titlesuffix
{%- block htmltitle %} <title>{{ title|striptags|e }}{{ titlesuffix }}</title> {%- endblock %}
要自定义:1.确保conf.py中有templates_path = ['_templates']。1.在_templates目录中建立名为layout.html的档案。1.在layout.html中,添加以下内容:
templates_path = ['_templates']
{% extends "!layout.html" %} {%- set customtitlesuffix = " | "|safe + docstitle|e %} {%- block htmltitle %} <title>{{ title|striptags|e }}{{ customtitlesuffix }}</title> {%- endblock %}
另请参阅https://www.sphinx-doc.org/en/master/templating.html。
1条答案
按热度按时间iq3niunx1#
长破折号(
—
)来自layout.html模板:titlesuffix
的值在模板中稍靠后的位置使用:要自定义:
1.确保conf.py中有
templates_path = ['_templates']
。1.在_templates目录中建立名为layout.html的档案。
1.在layout.html中,添加以下内容:
另请参阅https://www.sphinx-doc.org/en/master/templating.html。