gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.69k stars 7.53k forks source link

Adding more documentation about Google Analytics template #1654

Closed digitalcraftsman closed 8 years ago

digitalcraftsman commented 8 years ago

I've recognized that the docs are missing an example of the built-in Google Analytics template and of the corresponding variable for the config file.

What would be a good place to insert them into the docs? Furthermore, the docs provide an example of a footer partial taken from the code of spf13.com.

Should I remove the GA part of this example?

/cc @anthonyfok @bep

cfjedimaster commented 8 years ago

Dumb question - but where exactly is this documented? I've been looking for a while now and can't find it.

cfjedimaster commented 8 years ago

Site variables (https://gohugo.io/templates/variables/), mentions .Site.GoogleAnalytics and says this:

"A string representing your tracking code for Google Analytics as defined in the site configuration."

Ok, so I go to configuration (https://gohugo.io/overview/configuration/) but I see nothing there.

digitalcraftsman commented 8 years ago

Hello @cfjedimaster,

I've integrated this feature shortly before the release of Hugo v0.15. But this didn't included the documentation. Since a while I'm waiting for feedback to add it.

However, you can enable the internal Google Analytics template by adding the following line to your theme:

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

Now, move to the config file and assign your tracking code to the corresponding variable:

googleAnalytics = ""

The template behaves similar to the one of Disqus. If googleAnalytics is not set or equals an empty string the internal template will not appear in your generated sites.

cfjedimaster commented 8 years ago

Thanks. Should the bug be reopened though?

digitalcraftsman commented 8 years ago

Which bug do you mean?

cfjedimaster commented 8 years ago

Well, it says, "I've recognized that the docs are missing an example of the built-in Google Analytics template.", and I guess I saw this as related, but maybe a new bug should be filed for the variable?

digitalcraftsman commented 8 years ago

Now, I understand what you mean. I've updated the first comment and mentioned the config variable explicitly.

but maybe a new bug should be filed for the variable

Both things are closely related. Therefore, I would keep them together in a single issue.

cfjedimaster commented 8 years ago

Cool, and thank you for the help.

On Fri, Jan 15, 2016 at 3:17 PM, digitalcraftsman notifications@github.com wrote:

Now, I understand. I've updated the first comment and mentioned the config variable explicitly.

but maybe a new bug should be filed for the variable

Both things are closely related. Therefore, I would keep them together in a single issue.

— Reply to this email directly or view it on GitHub https://github.com/spf13/hugo/issues/1654#issuecomment-172094733.

Raymond Camden, Developer Advocate for MobileFirst at IBM

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden

dherbst commented 8 years ago

I added pull request #1829, does this satisfy the documentation requirement?

digitalcraftsman commented 8 years ago

Hello @dherbst,

your commit seems to be fine. A new page in the extras-section is reasonable. I would have written the docs myself but I didn't got feedback about a location so far.

I would merge your commit if nobody has something to complain. @bep, @anthonyfok: do you agree?

anthonyfok commented 8 years ago

Looks good to me, @digitalcraftsman! Just make sure you change "Adds" to "Add" in the commit message. <grin, duck, run>

soaxelbrooke commented 6 years ago

Newcomer to hugo here, and I'm not able to get this working with the existing documentation. Is it out of date?

soaxelbrooke commented 6 years ago

For those that stumble on this, I was helped by this example footer.html, where you just replace the literal UA value with {{ .Site.GoogleAnalytics }}, after you've set googleAnalytics = "UA-0000000-00" in your config.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.