6

I am using read the docs theme to create a HTML content using sphinx. In the theme, I want to edit the hyperlink for "Edit on Github" section. I am able to enable or disable the link using the following variables in the conf.py file.

html_context = {
    'display_github': True,
    'github_repo': 'xyz',
               }`

This results in the following link https://github.com/xyz

  1. However, we have an internal GitLab repo in our company and I want to change the link to https://github.companyname.com/xyz

  2. Also, is there a variable in the theme to specify the branch name?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
tribe
  • 61
  • 2

2 Answers2

2

You can use the configuration value github_url to force the "Edit on GitHub" button to use the configured URL.

github_url = "https://github.companyname.com/xyz"

You can configure RTD to publish different branches of your documentation, if that is what you meant in your second question. We do this for Pyramid.

If you instead meant for the GitHub URL, there is no other special variable to include the branch in the URL for the "Edit on GitHub" button. You can do that manually in each branch's conf.py for github_url, say for example on the my-branch branch:

github_url = "https://github.companyname.com/my-branch/xyz"

Then when the branch is published on RTD, then each branch will have its own link to that branch's reST source.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
-1

I added

rst_prolog = """
:github_url: https://github.com/torvalds/linux
"""

in conf.py to change the link for the Edit On GitHub button on every page

Carlo Revelli
  • 50
  • 2
  • 5
  • For me, that just makes the Edit on Github page go to that one static URL from all pages rather than the github version of the current page. – partofthething Sep 22 '21 at 16:39