{"id":2578,"date":"2023-02-13T06:37:16","date_gmt":"2023-02-13T12:37:16","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=2578"},"modified":"2023-02-12T16:56:22","modified_gmt":"2023-02-12T22:56:22","slug":"setting-up-giscus-comments-on-wordpress","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=2578","title":{"rendered":"Setting up Giscus Comments on WordPress"},"content":{"rendered":"\n<p>This blog was setup originally in 2016 and has never had a really useful comments section. There was a time when the only thing showing up were trackbacks to malicious websites. This wasn&#8217;t exactly a positive addition, so I disabled trackbacks and commenting to prevent any misleading comments. I decided to try and get a comments section back and operational as a part of my overhaul of my webserver (and having recently learned of Giscus for using GitHub accounts and backend for commenting). So here we have a guide for setting up Giscus comments on WordPress.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Giscus<\/h2>\n\n\n\n<p>Setting up Giscus is pretty straight forward. We&#8217;ll be following the <a rel=\"noreferrer noopener\" href=\"https:\/\/giscus.app\/\" target=\"_blank\">instructions in the documentation <\/a>for getting things setup and also to create the code we need to link the blog to Giscus. We need a GitHub repository with discussions enabled and the Giscus app installed on for our blog to use as the backend for comments. We&#8217;ll start by creating a public repository to use for the blog, as I don&#8217;t intend on using one of my code repositories for blog discussions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"1024\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-9-833x1024.png\" alt=\"\" class=\"wp-image-2618\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-9-833x1024.png 833w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-9-244x300.png 244w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-9-768x944.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-9.png 910w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Create a new repository and set it to public<\/figcaption><\/figure>\n\n\n\n<p>Now that we have the repository created, we&#8217;ll go to the General Settings section on the repo. Here we will enable the discussions feature.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-10-1024x300.png\" alt=\"\" class=\"wp-image-2620\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-10-1024x300.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-10-300x88.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-10-768x225.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-10.png 1423w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Go to the repositories general settings<\/figcaption><\/figure>\n\n\n\n<p>I just checked the Discussions checkbox, clicking the setup button did nothing in my browser, so I have a feeling that isn&#8217;t necessary (also it worked fine after without going through that setup).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"528\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-11-1024x528.png\" alt=\"\" class=\"wp-image-2621\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-11-1024x528.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-11-300x155.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-11-768x396.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-11.png 1185w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Enable Discussions<\/figcaption><\/figure>\n\n\n\n<p>Now that discussions are enabled, we want to Install the Giscus app on our repository. We start by going to the <a href=\"https:\/\/github.com\/apps\/giscus\">Giscus app page<\/a> and clicking install.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"339\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12-1024x339.png\" alt=\"\" class=\"wp-image-2622\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12-1024x339.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12-300x99.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12-768x254.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12-1536x509.png 1536w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-12.png 1600w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Go to the giscus app page and hit install<\/figcaption><\/figure>\n\n\n\n<p>The installation defaults to all repositories, which we don&#8217;t want to do at the moment. I&#8217;m going to only select the repository I created for the blog discussions\/comments as the repository to install Giscus on. This can always be changed later on.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"1024\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-13-705x1024.png\" alt=\"\" class=\"wp-image-2623\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-13-705x1024.png 705w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-13-206x300.png 206w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-13-768x1116.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-13.png 821w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><figcaption class=\"wp-element-caption\">Select your repo to install Giscus to<\/figcaption><\/figure>\n\n\n\n<p>Now that our repository is setup, we go back to the Giscus app page. We can fill in the repository field with the one we just created and configured. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"184\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-14.png\" alt=\"\" class=\"wp-image-2624\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-14.png 695w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-14-300x79.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><figcaption class=\"wp-element-caption\">Giscus repository<\/figcaption><\/figure>\n\n\n\n<p>I never setup WordPress to use pretty links, but either way I&#8217;ll be using the URL based comment linking. This will link to the blog post numbers, which are static and unchanging (unlike the titles I create while writing). This method just seemed simple and foolproof even if on the GitHub discussions, the titles will be a little non-sensical.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"656\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-15-1024x656.png\" alt=\"\" class=\"wp-image-2625\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-15-1024x656.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-15-300x192.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-15-768x492.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-15.png 1166w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Giscus page mappings<\/figcaption><\/figure>\n\n\n\n<p>For the discussion category, I went with the suggested default value, announcements.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"267\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-16-1024x267.png\" alt=\"\" class=\"wp-image-2626\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-16-1024x267.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-16-300x78.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-16-768x200.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-16.png 1198w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Discussion category<\/figcaption><\/figure>\n\n\n\n<p>Finally we reach the last option on the Giscus setup page, feature selection. The only feature that I have selected so far is to enable reactions on the main past, which will show emoji reactions before the comments section underneath. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-17-1024x609.png\" alt=\"\" class=\"wp-image-2627\" width=\"674\" height=\"400\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-17-1024x609.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-17-300x179.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-17-768x457.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-17.png 1200w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><figcaption class=\"wp-element-caption\">Feature selection<\/figcaption><\/figure>\n\n\n\n<p>Finally we&#8217;ll copy the Giscus script code from the page and we&#8217;ll be pasting that into our comments code for WordPress.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring WordPress to use Giscus<\/h2>\n\n\n\n<p>I started out by digging around trying to find a good place to put the new Giscus comments code. I ended up finding the comments.php file using the theme file editor. This sounded like the best place to put it as it&#8217;ll show up wherever the WordPress based comments would have shown. Just as a reference, I&#8217;ve posted a screenshot from the original WordPress comments section code below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"867\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-21-1024x867.png\" alt=\"\" class=\"wp-image-2643\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-21-1024x867.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-21-300x254.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-21-768x650.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-21.png 1392w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">The OLD comments.php source code from my theme<\/figcaption><\/figure>\n\n\n\n<p>I removed everything from the comments DIV as well as the if post_password_required logic above it. I wanted the Giscus comments to always be shown on the posts. I can always add this back in if wanted later on. Then I pasted the generated Giscus comments script in the comments DIV (I omitted some of the code for the screenshot, leave all that in for production). <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"644\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19-1024x644.png\" alt=\"\" class=\"wp-image-2630\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19-1024x644.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19-300x189.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19-768x483.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19-1536x966.png 1536w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-19.png 1699w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">The NEW comments.php source code for my theme<\/figcaption><\/figure>\n\n\n\n<p>With code saved in place, it was time to check out a post or two and add some test comments!<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"974\" data-id=\"2635\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-20-1024x974.png\" alt=\"\" class=\"wp-image-2635\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-20-1024x974.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-20-300x285.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-20-768x730.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-20.png 1095w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">New comments section<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"907\" height=\"966\" data-id=\"2634\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-18.png\" alt=\"\" class=\"wp-image-2634\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-18.png 907w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-18-282x300.png 282w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2023\/02\/image-18-768x818.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Working comments section with some contents<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Now that comments are enabled and working again, only time will tell if this was a good idea and will get used by viewers of my blog. I like that its back and available either way, and the process of setting it up was straightforward and simple enough to do. No matter what, its easier than handling individual users on my WordPress for commenting alone, and easier for them when they probably already have a GitHub account.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/giscus.app\/\" target=\"_blank\">Giscus Documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/apps\/giscus\" target=\"_blank\" rel=\"noreferrer noopener\">Giscus GitHub App<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/blog.arkey.fr\/2022\/10\/16\/moving-from-disqus-to-giscus\/\">Blog about moving from Discus to Giscus<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.lprp.fr\/2022\/11\/Migrate-wordpress-comments-to-giscus\/\" target=\"_blank\" rel=\"noreferrer noopener\">Blog on migrating WordPress comments to Giscus<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This blog was setup originally in 2016 and has never had a really useful comments section. There was a time when the only thing showing up were trackbacks to malicious websites. This wasn&#8217;t exactly a positive addition, so I disabled trackbacks and commenting to prevent any misleading comments. I decided to try and get a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=2578\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up Giscus Comments on WordPress&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2634,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[89,22,41,86],"class_list":["post-2578","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-giscus","tag-services","tag-webservers","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2578"}],"version-history":[{"count":26,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2578\/revisions"}],"predecessor-version":[{"id":2659,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2578\/revisions\/2659"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/media\/2634"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}