Skip to content

Adding a comment system

  1. Install the Giscus GitHub App and grant access to the repository that should host comments as GitHub discussions. Note that this can be a repository different from your documentation.
  2. Visit Giscus and generate the snippet through their configuration tool to load the comment system. Copy the snippet for the next step. The resulting snippet should look similar to this:

    <script src="https://giscus.app/client.js"
            data-repo="speaknowpotato/mkdocs-template"
            data-repo-id="R_kgDOIPlEiw"
            data-category="General"
            data-category-id="DIC_kwDOIPlEi84CSPcD"
            data-mapping="pathname"
            data-strict="0"
            data-reactions-enabled="1"
            data-emit-metadata="0"
            data-input-position="top"
            data-theme="preferred_color_scheme"
            data-lang="en"
            crossorigin="anonymous"
            async>
    </script>
    
    3. Add theme extension and override the comments.html. More details could be found in Setup and theme structure.

    1. Create a new folder overrides in the relative folder. Example

    2. Change theme/custom_dir to overrides in mkdocs.yml Example

    3. Update comments.html Example

  3. Enable comment, add the following lines to each markdown file that you want to have comment system.

    ---
    comments: true
    ---
    

Reference

  1. Adding a comment system

Last update: 2022-10-30
Created: 2022-10-30

Comments