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

Add hosted_on variable for a link in the footer #165

Merged
merged 2 commits into from
Jan 27, 2024
Merged

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jan 26, 2024

Helps python/docs-community#5.

If hosted_on is defined in your docs' conf.py:

html_theme_options = {
    'collapsiblesidebar': True,
    'hosted_on': '<a href="https://example.com">Example</a>',
    'issues_url': '/bugs.html',
    'license_url': '/license.html',
    'root_include_title': False   # We use the version switcher instead.
}

Adds a "Hosted by" line to the footer:

image

Conditional

For python/docs-community#5, we can instead add this in conf.py:

if os.getenv("READTHEDOCS"):
    html_theme_options["hosted_on"] = '<a href="https://about.readthedocs.com/">Read the Docs</a>'

And we'll only get the "Hosted by" line for builds created on Read the Docs:

image

Here's a demo build:

If you build that locally or on another server which doesn't have the env var defined, we don't get the link:

image

Copy link
Contributor

@willingc willingc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @hugovk

@hugovk hugovk merged commit 3f45850 into python:main Jan 27, 2024
11 checks passed
@hugovk hugovk deleted the hosted-on branch January 27, 2024 14:53
@hugovk
Copy link
Member Author

hugovk commented Jan 29, 2024

This has now been released, so here's the follow-up: python/cpython#114697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants