diff --git a/exampleSite/content/docs/guide/configuration.md b/exampleSite/content/docs/guide/configuration.md index 0044c92..bf1e248 100644 --- a/exampleSite/content/docs/guide/configuration.md +++ b/exampleSite/content/docs/guide/configuration.md @@ -197,3 +197,12 @@ There are three available options: `full`, `wide`, and `normal`. By default, the page width is set to `normal`. Similarly, the width of the navbar and footer can be customized by the `params.navbar.width` and `params.footer.width` parameters. + + +### Google Analytics + +To enable Google Analytics, set the `googleAnalytics` parameter in the config file: + +```yaml {filename="hugo.yaml"} +googleAnalytics: G-XXXXXXXXXX +``` diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 74a271e..6f66935 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -7,6 +7,8 @@ enableGitInfo: true # enableEmoji: false hasCJKLanguage: true +# googleAnalytics: G-XXXXXXXXXX + outputs: home: [HTML] page: [HTML] diff --git a/layouts/partials/google-analytics.html b/layouts/partials/google-analytics.html new file mode 100644 index 0000000..3fd65aa --- /dev/null +++ b/layouts/partials/google-analytics.html @@ -0,0 +1,13 @@ +{{ with .Site.GoogleAnalytics }} + + + +{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index cf3904a..1e342c8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -16,10 +16,21 @@ {{ end -}} + {{ partial "opengraph.html" . }} {{ template "_internal/schema.html" . -}} {{ template "_internal/twitter_cards.html" . -}} + {{ partialCached "head-css.html" . }} + + + + {{- if and .Site.GoogleAnalytics (eq hugo.Environment "production") }} + + {{ partial "google-analytics.html" . }} + {{- end }} + +