From f7ec46dd80e35339aa6e0968f8cdb807bce051ed Mon Sep 17 00:00:00 2001 From: Hidetoshi Yanagi Date: Mon, 18 May 2026 16:25:14 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E3=83=96=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E8=A8=98=E4=BA=8B=E6=9C=AB=E5=B0=BE=E3=81=AB=20Google=20AdSens?= =?UTF-8?q?e=20=E5=BA=83=E5=91=8A=E3=82=92=E8=BF=BD=E5=8A=A0=20(#28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - static/ads.txt を追加(Google AdSense 認証用) - hugo.toml に adsensePublisher / adsenseSlot パラメータを追加 - layouts/partials/head/extensions.html で AdSense スクリプトを注入 - layouts/partials/posts/adsense.html で記事末尾に広告ユニットを表示 - adsenseSlot が未設定の場合は広告を非表示にする Co-Authored-By: Claude Sonnet 4.6 --- hugo.toml | 3 +++ layouts/partials/head/extensions.html | 3 +++ layouts/partials/posts/adsense.html | 11 +++++++++++ layouts/posts/single.html | 2 ++ static/ads.txt | 1 + 5 files changed, 20 insertions(+) create mode 100644 layouts/partials/head/extensions.html create mode 100644 layouts/partials/posts/adsense.html create mode 100644 static/ads.txt diff --git a/hugo.toml b/hugo.toml index 5453b5a..fe548e4 100644 --- a/hugo.toml +++ b/hugo.toml @@ -38,6 +38,9 @@ theme = 'hugo-coder' dateFormat = "2006-01-02" + adsensePublisher = "ca-pub-0944887782985208" + # adsenseSlot = "" # AdSense 管理画面で広告ユニットを作成後、スロット ID を設定する + commit = "https://github.com/daruyanagi/daruyanagi.github.io/tree/" [taxonomies] diff --git a/layouts/partials/head/extensions.html b/layouts/partials/head/extensions.html new file mode 100644 index 0000000..83cc5d0 --- /dev/null +++ b/layouts/partials/head/extensions.html @@ -0,0 +1,3 @@ +{{ with .Site.Params.adsensePublisher }} + +{{ end }} diff --git a/layouts/partials/posts/adsense.html b/layouts/partials/posts/adsense.html new file mode 100644 index 0000000..5999c41 --- /dev/null +++ b/layouts/partials/posts/adsense.html @@ -0,0 +1,11 @@ +{{ with .Site.Params.adsenseSlot }} +
+ + +
+{{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index aea4916..2d1a50b 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -31,6 +31,8 @@

{{ .Content }} + {{ partial "posts/adsense.html" . }} +