4

I'm trying to find out how to use the _template overrides option in Sphinx to override the default ReadTheDocs theme for hosting Sphinx documentation on http://readthedocs.org.

Specifically, I'm wanting to remove/hide the "Edit on Github" link shown in the upper right hand corner of this theme.

Any tips would be greatly appreciated! Thanks!

I've reviewed the documentation here: http://www.sphinx-doc.org/en/stable/templating.html, however, I'm stumped and really need some help.

Thank you!

Brian King
  • 474
  • 3
  • 13

3 Answers3

13

Okay, I figured it out so I'll answer my own inquiry in hopes to assist others.

Assuming you're using the ReadTheDocs default theme this should work just fine.

  • Clone the ReadTheDocs theme from the Github repo to your computer. (https://github.com/snide/sphinx_rtd_theme/)
  • Locate breadcrumbs.html file (https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/breadcrumbs.html)
  • Add breadcrumbs.html file to your Sphinx documentation folder in the _templates folder. If this directory doesn't yet exist you'll need to create it.
  • In your conf.py file locate your html_context section, if you do not already have this, you can create it. (Sample linked below).

    html_context = { "display_github": False, # Add 'Edit on Github' link instead of 'View page source' "last_updated": True, "commit": False, }

  • Add the breadcrumbs.html file to your tracked files using Git

  • Commit the changes to your conf.py
  • Push to remote Github repo
  • Profit

References

Brian King
  • 474
  • 3
  • 13
1

The Read the Docs documentation has similar instructions: https://docs.readthedocs.io/en/latest/guides/remove-edit-buttons.html#. So perhaps there've been underlying code changes since the original answer was posted.

1

My needs was very similar but not exactly the same. I wanted to both remove this link for generated pages ("search" and "genindex"), and change the link text because we use framagit as a project hosting.

Here is my version at the end:

{%- extends "sphinx_rtd_theme/breadcrumbs.html" %}

{% block breadcrumbs_aside %}
  <li class="wy-breadcrumbs-aside">
    {% if hasdoc(pagename) and pagename != "search" and pagename != "genindex" %}
      <a href="{{ meta['framagit_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on FramaGit') }}</a>
    {% endif %}
  </li>
{% endblock %}

See it live here: https://framagit.org/simgrid/simgrid/tree/master/docs/source

Martin Quinson
  • 1,347
  • 8
  • 16