hugo-sid / hugo-blog-awesome

Fast, minimal blog with dark mode support.

Home Page:https://hba.sid.one

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Analytics not working

songofroland opened this issue · comments

Describe the bug
The Google Analytics script is not injected to the <head> element of the build site.

Steps to reproduce

  1. Build the site (run hugo)
  2. Check public/index.html
  3. ctr-f gtag - nothing is found.

Expected behavior
The Google Analytics js script should be injected.

Device information (please complete the following information):

  • OS: MacOS (ARM)
  • Version: hugo v0.111.3+extended darwin/arm64 BuildDate=unknown
  • Theme latest commit: ce9f89b

Additional context

Moving googleAnalytics variable to the top of the config.toml seems to resolve the issue.

This does not work:

baseURL = 'example.com
languageCode = 'en-us'
title = 'Lorem Ipsum'
theme = 'hugo-blog-awesome'

[[params.socialIcons]]
name = "Rss"
url = "index.xml"

# To enable Google Analytics 4 (gtag.js) provide G-MEASUREMENT_ID below.
# To disable  Google Analytics, simply leave the field empty or remove the next line
googleAnalytics = 'G-MEASUREMENT_ID' # G-MEASUREMENT_ID

and this does inject:

baseURL = 'example.com
languageCode = 'en-us'
title = 'Lorem Ipsum'
theme = 'hugo-blog-awesome'
googleAnalytics = 'G-MEASUREMENT_ID' # G-MEASUREMENT_ID

[[params.socialIcons]]
name = "Rss"
url = "index.xml"

Should I open a PR?

commented

Hi @songofroland .

First, thanks for checking out this theme and starring the repo.

Thanks for putting all the information and creating a detailed issue.

Should I open a PR?

Please open a PR with the fix.

@hugo-sid thanks for the quick follow-up.

By working on PR I've noticed the config in this repo is correct. It must have been an error on my end when pasting the social icons configs.

It's really, really counter-intuitive that the ordering of the config matters.

Anyways, sorry for the confusion. The issue can be closed.

commented

It's fine @songofroland . No worries.

I'm happy that you were able to sort it out yourself.

Have a nice day. Happy blogging :)