Inject Partials#

The theme provides empty partial templates at key points in the page layout. Override these to inject custom HTML without modifying the base templates.

Create matching files in your project’s layouts/_partials/docs/inject/ directory.

PartialLocation
inject/head.htmlInside <head>, e.g. meta tags, stylesheets, scripts
inject/body.htmlBefore </body>, e.g. analytics, chat widgets, scripts
inject/menu-before.htmlBefore the sidebar menu
inject/menu-after.htmlAfter the sidebar menu
inject/content-before.htmlBefore the page content
inject/content-after.htmlAfter the page content
inject/toc-before.htmlBefore the table of contents
inject/toc-after.htmlAfter the table of contents
inject/footer.htmlInside the page footer

Example#

To add a Google Analytics script, create layouts/_partials/docs/inject/head.html

{{ with .Site.Params.googleAnalytics }}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
{{ end }}

To add a custom banner above every page, create layouts/_partials/docs/inject/content-before.html

<div class="my-banner">
  This documentation is for version 2.0. See <a href="/v1/">version 1.0 docs</a>.
</div>