How to automatically set the 'site_url' of an MkDocs site to the bound domain? #6591
-
I encountered a small issue where I deployed the same mkdocs-material site to different platforms like GitHub Pages, Netlify, etc., and attached different domain names. For instance, I bound 'https://ggg.com/' to GitHub Pages and 'https://nnn.com/' to Netlify. However, in my Therefore, I'd like to ask if there's a way to automatically point the 'site_url' of the mkdocs-material site to the bound domain? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @shenweiyan, I guess, the "right" thing to do would likely be to split up the deployment process for each of your domains, create separate GitHub Actions that each set a different environmental variable and then load that variable using However, if you're looking for a quicker fix that just deals with the logo button, then you can create some post-processing JavaScript that modifies the domain in the link to the |
Beta Was this translation helpful? Give feedback.
Hello @shenweiyan,
the HTML is generated once during build, and the
site_url
is used in more places than just the logo home button.I guess, the "right" thing to do would likely be to split up the deployment process for each of your domains, create separate GitHub Actions that each set a different environmental variable and then load that variable using
!ENV
in themkdocs.yml
file:https://docs.github.com/en/actions/learn-github-actions/variables
https://www.mkdocs.org/user-guide/configuration/#environment-variables
This will increase CI time, but I'm assuming it shouldn't be an issue. I don't know whether you can use
matrix
in this instance to parallelize the deployment to different bran…