Skip to content

Using html_context Variables for build to different environments #97

Open
@coding-to-music

Description

@coding-to-music

Using html_context Variables
https://jareddillard.com/blog/common-ways-to-customize-sphinx-themes.html#using-html-context-variables

Passing in custom configuration overrides at runtime can come in handy when deploying to different environments. To take advantage of custom configuration overrides at runtime, add html_context flags to the sphinx-build command:

sphinx-build -E -b html
-D html_context.display_github=true
-D html_context.github_user=sphinx-doc
-D html_context.github_repo=sphinx
-D html_context.github_version=master/source/
-d ./build/doctrees
./source
./build
Then reference them in the theme’s HTML template:

{% if display_github %}
<a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode|default("blob") }}/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-github"> {{ _('Edit on GitHub') }}
{% endif %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions