This is more of a question - is there some way to use ENV variables in mkdocs.yml? The thing is that I want to automatically deploy to gh-pages when the build is successful, but I don't want to expose my Google Analytics tokens. Would be awesome!
Digging into PyYAML, I can answer my own question:
google_analytics:
- !!python/object/apply:os.getenv ["GOOGLE_ANALYTICS_TOKEN"]
- auto
@squidfunk , do you know if it is possible to add non strings this way ?
This doesn't work:
plugins:
- search
- pdf-export:
combined: !!python/object/apply:os.getenv ["PDF_EXPORT_COMBINED"]
The build complains that string is not bool value:
PS> $Env:PDF_EXPORT_COMBINED='true'
PS> mkdocs build
...
ERROR - Config value: 'plugins'. Error: Plugin value: 'combined'.
Expected type: <class 'bool'> but received: <class 'str'>
I looked into PyYAML section _YAML tags and Python types_[^1] to no avail. I guess form:
!!python/object/apply:module.f | value of聽f(...)
could be used as I need pythons distutils.util.strtobool( os.getenv("PDF_EXPORT_COMBINED") ) but not sure if that is possible using that syntax.
@majkinetor don't know, sorry. I'm not proficient in Python.
Most helpful comment
Digging into PyYAML, I can answer my own question: