Hugo Quick Start

Install

1
brew install hugo

Check the version

1
hugo version

Create a New Site

1
hugo new site XXX

Add Posts

1
hugo new posts/XXX.md

Start the Hugo server

1
2
# Draft
hugo server -D

Navigate to your new site at http://localhost:1313/.

Build

1
2
3
hugo -D
# or
hugo

Output will be in ./public/ directory by default.

Add Disqus

  1. Go to Disqus: https://disqus.com/
  2. Get started -> I want to install Disqus on my site
  3. config.yml 設定 disqusShortname
1
2
# Change it to your Disqus shortname before using
disqusShortname: xxx
  1. 新增 layouts/partials/disqus.html 並貼上:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<div id="disqus_thread"></div>
<script type="text/javascript">

(function() {
    // Don't ever inject Disqus on localhost--it creates unwanted
    // discussions from 'localhost:1313' on your Disqus account...
    if (window.location.hostname == "localhost")
        return;

    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    var disqus_shortname = '{{ .Site.DisqusShortname }}';
    dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

Reference

https://gohugo.io/getting-started/quick-start/ https://gohugo.io/templates/internal/#disqus

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus