arrow_back
Back

Hugo integrations: Google Analytics, Disqus, and RSS feeds

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Google Analytics

Add the measurement ID to the site config. Older Hugo docs used Universal Analytics (UA-…) with _internal/google_analytics_async.html. Prefer open_in_new GA4 with the current internal template for your Hugo version:

googleAnalytics = "G-XXXXXXXXXX"

In the head partial:

{{ template "_internal/google_analytics.html" . }}

(or _internal/google_analytics_async.html on older Hugo).

Disqus

disqusShortname = "shortname-from-disqus-service"
<section class="comments">
  <h3>Comments</h3>
  {{ if .Params.disableComments }}
    <p>Comments are disabled for this post</p>
  {{ else }}
    {{ template "_internal/disqus.html" . }}
  {{ end }}
</section>

Set disableComments: true in front matter to skip Disqus on a page.

RSS

Hugo builds RSS 2.0 feeds by default: /index.xml for the site and /section/index.xml for sections.

Link alternative formats from the head — see templates (.AlternativeOutputFormats). A simple manual tag looks like:

<link rel="alternate" type="application/rss+xml" href="https://example.com/index.xml" title="Feed">
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Webpack with Hugo: theme assets, npm scripts, and watch mode

arrow_forward