All guides

Install Foresite on MkDocs

These steps work for Material for MkDocs and MkDocs' built-in themes.

  1. In mkdocs.yml, point the theme at a folder for your overrides:

    theme:
      name: material
      custom_dir: overrides
    
  2. Create overrides/main.html with your Foresite line in the extrahead block:

    {% extends "base.html" %}
    
    {% block extrahead %}
      <script defer src="https://t.foresite.dev/s/YOUR_SITE_ID.js"></script>
    {% endblock %}
    
  3. Build and deploy.

If you turned on Material's instant navigation (navigation.instant), Foresite still counts each page change as a pageview. Visits to localhost aren't counted, so test on your published docs: the Installation Check in Settings → Install turns green with the first pageview.