Sphinx

Sphinx is a powerful documentation generator that has many features for writing technical documentation. Sphinx is written in Python, and supports documentation written in reStructuredText and Markdown.

Minimal configuration required to build an existing Sphinx project on Read the Docs looks like this, specifying a python 3.x toolchain on Ubuntu, using the built-in mkdocs command, and defining the location of the installation requirements:

.readthedocs.yaml
   version: 2

   build:
      os: ubuntu-24.04
      tools:
         python: "3"

   sphinx:
      configuration: docs/conf.py

   python:
      install:
         - requirements: requirements.txt

Quick start

Configuring Sphinx and Read the Docs addons

For optimal integration with Read the Docs, make the optional following configuration changes to your Spinx config.

Set the canonical URL

A canonical URL allows you to specify the preferred version of a web page to prevent duplicated content.

Set your html_baseurl to your Read the Docs canonical URL using a Read the Docs environment variable:

conf.py
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")

Using Markdown with Sphinx

You can use Markdown using MyST and reStructuredText in the same Sphinx project. We support this natively on Read the Docs, and you can also use locally by installing myst-parser:

pip install myst-parser

Then in your conf.py:

extensions = ["myst_parser"]

You can now continue writing your docs in .md files and it will work with Sphinx.

See also

Getting started with MyST in Sphinx

How to migrate from reStructuredText to MyST Markdown

Learn how to use references between different Sphinx projects, for instance between subprojects

How to migrate from reStructuredText to MyST Markdown

Start writing Markdown in your existing reStructuredText project, or migrate it completely.

Example repository and demo

Example repository

https://github.com/readthedocs/test-builds/tree/full-feature

Demo

https://test-builds.readthedocs.io/en/full-feature

Further reading