diff --git a/docs/content/overview/introduction.md b/docs/content/overview/introduction.md index 4fb57a02d..701e24de2 100644 --- a/docs/content/overview/introduction.md +++ b/docs/content/overview/introduction.md @@ -127,6 +127,7 @@ Hugo boasts the following features: ### Additional Features * Integrated [Disqus](https://disqus.com/) comment support + * Integrated [Google Analytics](https://google-analytics.com/) support * Automatic [RSS](/layout/rss/) creation * Support for [Go](http://golang.org/pkg/html/template/), [Amber](https://github.com/eknkc/amber) and [Ace](http://ace.yoss.si/) HTML templates * Syntax [highlighting](/extras/highlighting/) powered by [Pygments](http://pygments.org/) @@ -183,4 +184,3 @@ as I have writing it. * [Join the Mailing List](/community/mailing-list/) * [Star us on GitHub](https://github.com/spf13/hugo) * [Discussion Forum](http://discuss.gohugo.io/) - diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index d8df44318..c8f668b55 100644 --- a/docs/content/templates/variables.md +++ b/docs/content/templates/variables.md @@ -127,6 +127,7 @@ Also available is `.Site` which has the following: **.Site.Author** A map of the authors as defined in the site configuration.
**.Site.LanguageCode** A string representing the language as defined in the site configuration.
**.Site.DisqusShortname** A string representing the shortname of the Disqus shortcode as defined in the site configuration.
+**.Site.GoogleAnalytics** A string representing your tracking code for Google Analytics as defined in the site configuration.
**.Site.Copyright** A string representing the copyright of your web site as defined in the site configuration.
**.Site.LastChange** A string representing the date/time of the most recent change to your site, based on the [`date` variable]({{< ref "content/front-matter.md#required-variables" >}}) in the front matter of your content pages.
**.Site.Permalinks** A string to override the default permalink format. Defined in the site configuration.
diff --git a/hugolib/site.go b/hugolib/site.go index 7fe9717a5..3fe0284af 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -106,6 +106,7 @@ type SiteInfo struct { Author map[string]interface{} LanguageCode string DisqusShortname string + GoogleAnalytics string Copyright string LastChange time.Time Permalinks PermalinkOverrides @@ -456,6 +457,7 @@ func (s *Site) initializeSiteInfo() { LanguageCode: viper.GetString("languagecode"), Copyright: viper.GetString("copyright"), DisqusShortname: viper.GetString("DisqusShortname"), + GoogleAnalytics: viper.GetString("GoogleAnalytics"), BuildDrafts: viper.GetBool("BuildDrafts"), canonifyURLs: viper.GetBool("CanonifyURLs"), preserveTaxonomyNames: viper.GetBool("PreserveTaxonomyNames"), diff --git a/tpl/template_embedded.go b/tpl/template_embedded.go index e31bcf179..f7bd1b20e 100644 --- a/tpl/template_embedded.go +++ b/tpl/template_embedded.go @@ -202,6 +202,18 @@ func (t *GoHTMLTemplate) EmbedTemplates() { +{{ end }}`) + + t.AddInternalTemplate("", "google_analytics.html", `{{ with .Site.GoogleAnalytics }} + {{ end }}`) }