Skip to content

Change block overrides depending on OS environment variabled #5842

Answered by squidfunk
Enn83 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for asking. #5803 was also immediately coming to my mind. You can use environment variables in MkDocs, so something like this should work, setting the branch name to master by default:

extra:
  branch: !ENV [BRANCH, "master"]

And then call MkDocs like so:

BRANCH=`git branch --show-current` mkdocs build

In your override:

{% if config.extra.branch != "master" %}
  {% block announce -%}
    Be careful, you are currently reading the documentation for a branch under development: {{ config.extra.branch }}.
  {%- endblock %}
{% endif %}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Enn83
Comment options

@squidfunk
Comment options

@Enn83
Comment options

@squidfunk
Comment options

@Enn83
Comment options

Answer selected by Enn83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants