Skip to content

Add hosted_on variable for a link in the footer - #165

Merged
hugovk merged 2 commits into
python:mainfrom
hugovk:hosted-on
Jan 27, 2024
Merged

Add hosted_on variable for a link in the footer#165
hugovk merged 2 commits into
python:mainfrom
hugovk:hosted-on

Conversation

@hugovk

Copy link
Copy Markdown
Member

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:

ifos.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

@willingcwillingc left a comment

Copy link
Copy Markdown
Contributor

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:mainJan 27, 2024
@hugovk
hugovk deleted the hosted-on branch January 27, 2024 14:53
@hugovk

Copy link
Copy Markdown
MemberAuthor

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@hugovk@willingc