diff options
author | Jiawei Huang | 2020-06-14 14:05:14 -0700 |
---|---|---|
committer | Jiawei Huang | 2020-06-14 14:11:54 -0700 |
commit | 398ca6e2f300cce5c7bf7fa69fde42b4b592f5a4 (patch) | |
tree | b1c500b6d8a9df942f9c1f42b31149a45fcef8df | |
parent | 1a9b75fa6216334d0a9a1c379dba212888ce6f76 (diff) | |
download | hugo-theme-fuji-398ca6e2f300cce5c7bf7fa69fde42b4b592f5a4.tar.gz hugo-theme-fuji-398ca6e2f300cce5c7bf7fa69fde42b4b592f5a4.tar.bz2 hugo-theme-fuji-398ca6e2f300cce5c7bf7fa69fde42b4b592f5a4.zip |
Add preliminary Google AdSense support
When `googleAdsense` is set in `config.toml`, the AdSense code snippet
will be inserted between the `<head></head>` tags of your site. Only
Google AdSense Auto ads is supported at the moment.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | exampleSite/config.toml | 4 | ||||
-rw-r--r-- | layouts/partials/head.html | 9 |
3 files changed, 14 insertions, 1 deletions
@@ -68,7 +68,7 @@ Inside the folder of your Hugo site run: $ git submodule update --remote --merge ``` -## ⚙️ Configration +## ⚙️ Configuration ### 🎨 Favicon diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 72e22b7..4ba95b6 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -29,6 +29,10 @@ paginate = 10 # googleAnalyticsTid = "UA-000000000-0" # googleAnalyticsRoute = "https://*.*.workers.dev/" + # Google AdSense + # The AdSense code will be inserted between the head tags of your site. + # googleAdsense = "0000000000000000" + # Word counter and read time indicator in post metadata showWordCounter = true showReadTime = false diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 0603c4d..b953cd8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -41,6 +41,15 @@ <link rel="stylesheet" href="{{ "/assets/css/fuji.min.css" | relURL }}" /> {{ end }} +{{ if .Site.Params.googleAdsense }} +<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> +<script> + (adsbygoogle = window.adsbygoogle || []).push({ + enable_page_level_ads: true, + google_ad_client: "ca-pub-{{.Site.Params.googleAdsense}}", + }); +</script> +{{ end}} {{ if .Params.playerURL }} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css" /> {{ end }} |