Analytics and SEO

Add Google Analytics tracking to your site and learn about the page description meta tag.

Adding Analytics

The theme builds upon Hugo’s support for Google Analytics, which Hugo provides through internal templates. Once you set up analytics as described below, usage information for your site (such as page views) is sent to your Google Analytics account.

Prerequisites

You will need an analytics ID for your website before proceeding (technically it’s called a measurement ID or property ID but we’ll use the term “analytics ID” in this guide). If you don’t have one, see the How to get started section of Introducing Google Analytics 4 (GA4).

Setup

Enable Google Analytics by adding your project’s analytics ID to the site configuration file. For details, see [Configure Google Analytics][https://gohugo.io/templates/embedded/#google-analytics].

By default, this uses the gtag.js analytics library for both GA4 (which requires gtag.js) and Universal Analytics (UA) site tags. If you prefer using the older analytics.js library for your UA site tag, then set params.disableGtagForUniversalAnalytics to true in your project’s configuration file.

You can configure your project’s analytics ID by setting services.googleAnalytics.id in the Hugo configuration.

[services.googleAnalytics]
    id = 'G-12345'
+++
hide_feedback = true
+++
---

hide_feedback: true
---
{
    "hide_feedback": true
}

Disable feedback on all pages

Set params.ui.feedback.enable to false in hugo.toml/hugo.yaml/hugo.json:

[params.ui.feedback]
enable = false
params:
  ui:
    feedback:
      enable: false
{
  "params": {
    "ui": {
      "feedback": {
        "enable": false
      }
    }
  }
}

Search Engine Optimization meta tags

To learn how to optimize your site for SEO see, Search Engine Optimization (SEO) Starter Guide.

Google recommends using the description meta tag to tell search engines what your page is about. For each generated page, The theme will set the content of the meta description by using the first of the following that is defined:

For the template code used to perform this computation, see layouts/partials/page-description.html.

Add more meta tags as needed to your project’s copy of the head-end.html partial. For details, see Customizing templates.


Last modified July 22, 2024 : (9621835)