Jerry's Blog

Recording what I learned everyday

View on GitHub


15 April 2019

Add Comments in Your Blog

by Jerry Zhang

#Tip of the Day: Comparing with “996”, I work “7117”, working from 7am to 11pm and work 7 days per week. :D



If you want your reader to communicate with you by writing comments under your blog, you can use gittalk

Create OAuth Application in your github

Click here to register a new OAuth application

Application name: any name

Homepage URL: Your Blog's address

Application description: any description

Authorization callback URL: Your Blog's address

Save your Client ID and Client Secret!

Add Gitalk code in your template

I put the code at the end of my post template, i.e., /_layouts/post.html

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

<div id="gitalk-container"></div>

<script type="text/javascript">
    var gitalk = new Gitalk({
        clientID: 'GitHub Application Client ID',
        clientSecret: 'GitHub Application Client Secret',
        repo: 'your GitHub repo name',
        owner: 'GitHub repo owner',
        admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],
        id: decodeURI(location.pathname), // Ensure uniqueness and length less than 50
        distractionFreeMode: false  // Facebook-like distraction free mode
    })

    gitalk.render('gitalk-container')
</script>

Go to Gitalk github page

Congratulations! You have a comment area in your blog now!

tags: Jekyll - Comments