Adding Comments to Jekyll Minima Blog on Github Pages with Giscus
I wanted to start getting feedback for my github pages hosted jekyll minima backed blog posts. These could possibly be scathing drunkards furious with my methods, so that we may enter an educational debate, or simply feedback on how to improve areas as I am always busting to elevate my code! I came across giscus and found that this was very simple to do by backing it with github discussions as follows…
- Prerequisites
- Create Public Discussions Repo
- Generate Giscus Javascript
- Add Footer File to _includes Folder
- Comments Now Appear on Blog
Prerequisites
- Github Account
- Github pages blog backed with jekyll minima.
Create Public Discussions Repo
First create a public repo called “.discussions” in your github personal account or organisation.
Then you need to enable discussions on your github personal account or organisation.
Generate Giscus Javascript
Navigate to giscus app and enter the following details;
- The language for your comments
- The repo that contains your blog that you want comments on
- I set the discussions category to be announcements
- I chose the them to be light but you can choose what you like.
- I pretty much chose defaults for everything else…
It will genertae some code that looks something like this:
<div class="wrapper">
<script
src="https://giscus.app/client.js"
data-repo="hungovercoders-blog/datagriff"
data-repo-id="R_kgDOJT_U2A"
data-category="Announcements"
data-category-id="DIC_kwDOJT_U2M4CavN-"
data-mapping="pathname"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="light"
data-lang="en"
crossorigin="anonymous"
async
></script>
</div>
Add Footer File to _includes Folder
Add a footer file to the _includes folder of your blog repo.
Copy and paste this footer script sourced from Jekyll Minima source page into this footer file. Now add in the javascript that you generated from the giscus app. You directory structure and footer file content should look something like the below.
Comments Now Appear on Blog
You can now see the comments functionality on this blog post in the footer below and in all my previous posts! You can now add a comment by logging in with your github account and sending me some feedback. Easy peasy.
These comments also appear in the discussions of the blog repo as this is what backs this functionality.
Where you can navigate to the individual blog posts and see the comments as per the “data-mapping” setting that you applied in giscus.
I look forward to hearing from you!