如何使用 sphinx 生成 sitemap.xml 文件?
How do I generate a sitemap.xml file with sphinx?
Here it says: "The special entry name self stands for the document containing the toctree directive. This is useful if you want to generate a “sitemap” from the toctree." And I have been looking at this thred - Using self to create a sitemap with toctree in sphinx seem broken?。我似乎无法让它工作。
有没有我可以查看的由 sphinx 生成的站点地图的详细示例?
我最终在这个主题中使用了我自己的站点地图生成器。
https://github.com/guzzle/guzzle_sphinx_theme
# Import guzzle theme https://github.com/guzzle/guzzle_sphinx_theme
# Not actually using the theme but intead using the
# sitemap functionality and overriding the theme/templates in source/
html_translator_class = 'guzzle_sphinx_theme.HTMLTranslator'
html_theme_path = guzzle_sphinx_theme.html_theme_path()
html_theme = 'guzzle_sphinx_theme'
extensions.append("guzzle_sphinx_theme")
html_theme_options = {
"base_url": "YOURSITEURL"
}
我覆盖了源目录中的所有内容,除了站点地图生成器之外,我没有使用主题的任何其他部分。非常草率的解决方案,但它对我有用。
我知道这个问题已经有四年了,所以当时可能没有这个插件。我刚刚尝试了 sphinx-sitemap 插件,它对我有用。
集成很容易:
pip install sphinx-sitemap
然后在您的 config.py
集合中:
extensions = ['sphinx_sitemap']
html_baseurl = 'https://my-site.com/docs/'
然后正常生成站点。 sitemap.xml 将出现在项目的底部。它们还有一些高级功能,例如版本控制和多语言(我还没有尝试过)。
Here it says: "The special entry name self stands for the document containing the toctree directive. This is useful if you want to generate a “sitemap” from the toctree." And I have been looking at this thred - Using self to create a sitemap with toctree in sphinx seem broken?。我似乎无法让它工作。
有没有我可以查看的由 sphinx 生成的站点地图的详细示例?
我最终在这个主题中使用了我自己的站点地图生成器。 https://github.com/guzzle/guzzle_sphinx_theme
# Import guzzle theme https://github.com/guzzle/guzzle_sphinx_theme
# Not actually using the theme but intead using the
# sitemap functionality and overriding the theme/templates in source/
html_translator_class = 'guzzle_sphinx_theme.HTMLTranslator'
html_theme_path = guzzle_sphinx_theme.html_theme_path()
html_theme = 'guzzle_sphinx_theme'
extensions.append("guzzle_sphinx_theme")
html_theme_options = {
"base_url": "YOURSITEURL"
}
我覆盖了源目录中的所有内容,除了站点地图生成器之外,我没有使用主题的任何其他部分。非常草率的解决方案,但它对我有用。
我知道这个问题已经有四年了,所以当时可能没有这个插件。我刚刚尝试了 sphinx-sitemap 插件,它对我有用。
集成很容易:
pip install sphinx-sitemap
然后在您的 config.py
集合中:
extensions = ['sphinx_sitemap']
html_baseurl = 'https://my-site.com/docs/'
然后正常生成站点。 sitemap.xml 将出现在项目的底部。它们还有一些高级功能,例如版本控制和多语言(我还没有尝试过)。