Skip to main content

Sitemap generator for Sphinx

Project description

A Sphinx extension to silently generate a sitemaps.org compliant sitemap for the HTML version of your Sphinx Documentation.

Build Status PyPI version License: MIT

Installing

Directly install via pip by using:

pip install sphinx-sitemap

Add sphinx_sitemap to the extensions array in your Sphinx conf.py. For example:

extensions = ['sphinx_sitemap']

Set the value of html_baseurl in your Sphinx conf.py to the current base URL of your documentation. For example:

html_baseurl = 'https://my-site.com/docs/'

Note: html_baseurl was introduced in Sphinx 1.8.0. If you are using a version prior to that you must set your base URL to site_url instead.

For multilingual sitemaps, you have to generate a sitemap per language/locale and then manually add them to a sitemapindex file.

The extension will look at the language config value for the current language being built, and locale_dirs for the directory of alternate languages.

Note: It is currently opinionated, in that it will also use the version config value in the generated URL.

The end result is something like the following for each language/version build:

<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://my-site.com/docs/en/latest/index.html</loc>
    <xhtml:link href="https://my-site.com/docs/es/latest/index.html" hreflang="es" rel="alternate"/>
    <xhtml:link href="https://my-site.com/docs/fr/latest/index.html" hreflang="fr" rel="alternate"/>
    <xhtml:link href="https://my-site.com/docs/en/latest/index.html" hreflang="en" rel="alternate"/>
  </url>
  <url>
    <loc>https://my-site.com/docs/en/latest/about.html</loc>
    <xhtml:link href="https://my-site.com/docs/es/latest/about.html" hreflang="es" rel="alternate"/>
    <xhtml:link href="https://my-site.com/docs/fr/latest/about.html" hreflang="fr" rel="alternate"/>
    <xhtml:link href="https://my-site.com/docs/en/latest/index.html" hreflang="en" rel="alternate"/>
  </url>
</urlset>

See Who Is Using It

You can use GitHub search to see who is using sphinx-sitemap.

Contributing

Pull Requests welcome! See CONTRIBUTING for instructions on how best to contribute.

Maintaining PyPI Version

These are the steps for making a new Python package release.

  1. Rev versions in sphinx_sitemap/version.py and setup.py.

  2. Update CHANGELOG.md

  3. Create a tag and push to GitHub:

    git tag -a vX.Y.Z -m "Release vX.Y.Z"
    git push --tags origin master
  4. Upload the latest distribution:

    python setup.py sdist upload -r pypi

License

sphinx-sitemap is made available under a MIT license; see LICENSE for details.

Originally based on the sitemap generator in the guzzle_sphinx_theme project, also licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-sitemap-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file sphinx-sitemap-1.0.1.tar.gz.

File metadata

  • Download URL: sphinx-sitemap-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.2

File hashes

Hashes for sphinx-sitemap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2d1f1c17af44cb17d476e735b73c0d2c37b5b468c2557ef700c5a299e3eb844d
MD5 4a230633680ec2f069c1c3d5cc8cc160
BLAKE2b-256 1dfb010aca94e9232102a1f81b51f5dc3a764f884e570bf26a333fbab90d72ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page