How To insert extra tags into head block in base.html (mkdocs)
Summary
This is a short post to describe how to insert extra tags in to <head>
block in your doc or blog site built by mkdocs.
At the end you will see how I added adsense to my mkdocs site.
This post is going to follow the recommanded approach. For more detail see Overriding blocks.
Create overrides dir and main.html file
If this is not created, please create overrides dir. Then create main.html under it.
Note
This need to be created directly under your project dir.
Adding Overrides to mkdocs.yml
If this is not done, add below under theme to mkdocs.yml file in your project
Example
Below is how my mkdocs.yml looks like:
Adding content to main.html
Add below to html to insert additional tags into <head>
Example
Replace <script>...</script>
with your code. Below is an example of of you can add adsense to your mkdocs site.
Reference
Original Solution
Official Doc
Code that the solution replaces