Logo

Getting started

  • Tutorial
  • Adding a documentation project
  • Popular documentation tools
  • Example projects

Project setup and configuration

  • Configuration file overview
  • Configuration file reference
  • Read the Docs Addons
  • Account authentication methods
  • Automation rules
  • How to create reproducible builds

Build process

  • Build process overview
  • Build process customization
  • Git integration (GitHub, GitLab, Bitbucket)
  • Pull request previews
  • Build failure notifications
  • Environment variable overview
  • Environment variable reference

Hosting documentation

  • Versions
  • Subprojects
  • Localization and Internationalization
  • URL versioning schemes
  • Custom domains
  • Documentation notifications
  • Canonical URLs
  • Content Delivery Network (CDN) and caching
  • Sitemap support
  • 404 Not Found pages
  • robots.txt support

Reading documentation

  • Offline formats (PDF, ePub, HTML)
  • Visual diff
  • Link previews
  • How to embed content from your documentation
  • Server side search
  • Search query syntax
  • Flyout menu

Maintaining projects

  • Redirects
  • Traffic analytics
  • Search analytics
  • Security logs
  • Status badges
  • How to structure your documentation
  • Best practices for linking to your documentation
  • Security considerations for documentation pages

Business features

  • Business hosting
  • Organizations
  • Single Sign-On (SSO)
  • Sharing private documentation
  • How to manage your subscription
  • Privacy levels

How-to guides

  • Project setup and configuration
  • Build process
  • Upgrading and maintaining projects
  • Content, themes and SEO
    • Search engine optimization (SEO) for documentation projects
    • Using traffic analytics
    • Using search analytics
    • Enabling offline formats
    • Embedding content from your documentation
    • Managing translations for Sphinx projects
    • Supporting Unicode in Sphinx PDFs
    • Cross-referencing with Sphinx
    • Linking to other projects with Intersphinx
    • Using Jupyter notebooks in Sphinx
    • Migrating from rST to MyST
    • Adding custom CSS or JavaScript to Sphinx documentation
    • Adding "Edit Source" links on your Sphinx theme
      • GitHub
      • Bitbucket
      • Gitlab
      • Additional variables
  • Security and access
  • Account management
  • Best practice
  • Troubleshooting problems

Reference

  • Public REST API
  • Frequently asked questions
  • Changelog
  • About Read the Docs
  • Developer Documentation
  • Read the Docs website
Read the Docs user documentation
  • How-to guides: content, themes and SEO
  • Adding “Edit Source” links on your Sphinx theme
  • Edit on GitHub

Adding “Edit Source” links on your Sphinx theme

You can use define some Sphinx variables in the html_context to tell Read the Docs Sphinx theme to display “Edit Source” links on each page.

More information can be found on Sphinx documentation.

GitHub

If you want to integrate GitHub, these are the required variables to put into your conf.py:

html_context = {
    "display_github": True, # Integrate GitHub
    "github_user": "MyUserName", # Username
    "github_repo": "MyDoc", # Repo name
    "github_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_github %}
    <li><a href="https://github.com/{{ github_user }}/{{ github_repo }}
    /blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}.rst">
    Show on GitHub</a></li>
{% endif %}

Bitbucket

If you want to integrate Bitbucket, these are the required variables to put into your conf.py:

html_context = {
    "display_bitbucket": True, # Integrate Bitbucket
    "bitbucket_user": "MyUserName", # Username
    "bitbucket_repo": "MyDoc", # Repo name
    "bitbucket_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_bitbucket %}
    <a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}
    /src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}.rst'"
    class="icon icon-bitbucket"> Edit on Bitbucket</a>
{% endif %}

Gitlab

If you want to integrate Gitlab, these are the required variables to put into your conf.py:

html_context = {
    "display_gitlab": True, # Integrate Gitlab
    "gitlab_user": "MyUserName", # Username
    "gitlab_repo": "MyDoc", # Repo name
    "gitlab_version": "master", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

They can be used like this:

{% if display_gitlab %}
    <a href="https://{{ gitlab_host|default("gitlab.com") }}/
    {{ gitlab_user }}/{{ gitlab_repo }}/blob/{{ gitlab_version }}
    {{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-gitlab">
    Edit on GitLab</a>
{% endif %}

Additional variables

  • 'pagename' - Sphinx variable representing the name of the page you’re on.

Previous Next

© Copyright Read the Docs, Inc & contributors.

Built with Sphinx using a theme provided by Read the Docs.