pythonpython-sphinxsitemaptoctree

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?. I can't seem to get this to work.

Is there anywhere that has a detailed example of a sitemap being generated by sphinx I can look at?


Solution

  • I ended up using the sitemap generator in this theme with my own. 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"
    }
    

    I'm overriding everything in my source directory I'm not using any other parts of the theme other than the sitemap generator. Pretty sloppy solution but it worked for me.