Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with removing "Edit on Github" option with ReadTheDocs theme #2386

Closed
brianjking opened this issue Mar 18, 2016 · 9 comments
Closed

Help with removing "Edit on Github" option with ReadTheDocs theme #2386

brianjking opened this issue Mar 18, 2016 · 9 comments

Comments

@brianjking
Copy link

Hello,

When using http://readthedocs.org with the ReadTheDocs theme is it possible to remove the following elements? If so, how? I couldn't find anything in the documentation about this, if I overlooked it, please point me in the right direction.

  • Edit on Github link in header
  • In footer there's a "Revision #######" after the copyright message. Is there a way to remove this?

Thanks!

@shimizukawa
Copy link
Member

Sorry, I donkt know how to disable it because the feature is provided by readthedocs building system. So, please contact to https://github.com/rtfd/readthedocs.org or https://github.com/snide/sphinx_rtd_theme.

@xcriptus
Copy link

Hi,
you should try to put the following line in your conf.py file

html_show_sourcelink = False

I've no revision ### after the copyright. If you want to remove the revision in the title bar you can do

html_theme_options = {
    'display_version': False}

You can also have some fun with creating a _templates directory, look at the layout.html and create a file called _templates/layout.html with your modification. This is not too complex if you have some developement skills. Have a look at the "template" section of sphinx or jinja. For instance the following file add hello world in the side bar, and then "index" in the menu

{% extends "!layout.html" %}
{% block sidebartitle %}
    HELLO WORLD
    {{ super() }}

{% endblock %}
{% block menu %}
    {{ super() }}
    <li class="toctree-l1"><a class="reference internal" href="{{ pathto('genindex') }}">Index</a></li>
    <li class="toctree-l1"><a class="reference internal" href="{{ pathto('py-modindex') }}">Modules index</a></li>
{% endblock %}

Hope this helps.
Jean-marie

@brianjking
Copy link
Author

@escribis

I had already tried html_show_sourcelink = False and it does remove the view page source message when using make html locally on my machine. However, it doesn't do anything about the Edit on Github display when using readthedocs.org.

The suggestion of using the details below works great when using Sphinx only, but once again, not on readthedocs.org.

html_theme_options = { 'display_version': False}

readthedocs github suggested the _templates tweaks you've noted above, however, I don't have the experience necessary and am feeling lost.

Thanks for your help thus far, anything else you can do would be greatly appreciated.

Thanks & Cheers!

@brianjking
Copy link
Author

@escribis This is the template I'm using, are you saying I'd copy the source of it, remove the "edit on github" option, which I'm not even sure where it is based on a quick read of it, add this to my local repo and push for RTD to re-build it?

https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html

Thanks!

(If I had to guess the line I'd remove it would be this https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html#L147)

@brianjking
Copy link
Author

@escribis actually, found it in breadcrumbs.html, but using display_github with False doesn't seem to make it work, so please try and explain what all I would need to modify in breadcrumbs.html to get this working.

Thank you so much!

https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/breadcrumbs.html#L16-L19

@JimiC
Copy link

JimiC commented Apr 6, 2016

I found myself in your situation where I wanted to remove certain elements from the page. I ended up doing them via javascript. You know if you include

def setup(app):
    app.add_stylesheet('css/style.css?v=1')
    app.add_javascript('js/script.css?v=1')

in conf.py and have the corresponding folders under _static, you can style your pages and execute js on them.

@brianjking
Copy link
Author

Okay, I figured out the "Edit on Github" portion a while ago and thought I'd share my fixes here for anyone else looking to accomplish this.

I've also documented this on my StackOverflow question.

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

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

@benjaoming
Copy link
Contributor

This doesn't work right now because setting html_context in conf.py is broken. See: #2442

@MarSoft
Copy link

MarSoft commented Apr 1, 2019

Just for record, the right way is now documented here: https://docs.readthedocs.io/en/stable/guides/remove-edit-buttons.html

And if you want to only hide these links on some pages (e.g. on pages generated by autosummary which don't have corresponding github file anyway) then you can use that technique in combination with file-level metadata:

In breadcrumbs.html:

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

{% block breadcrumbs_aside %}
{% if not meta or meta.get('github_url') != 'hide' %}
{{ super() }}
{% endif %}
{% endblock %}

On the page which should not have github link, add to the very beginning:

:github_url: hide

g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 11, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 15, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 15, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 15, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 16, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 16, 2019
g1itch added a commit to g1itch/PyBitmessage that referenced this issue Oct 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants