How To Apply Google Adsense And Use For Hexo8 Version

How To Apply Google Adsense And Use For Hexo8 Version

這篇介紹How To Apply Google Adsense And Use For Hexo8 Version。

How To Apply Google Adsense

1
2
3
4
5
6
7
8
9
10
11
12
13
14
自建部落格從2019-2021剛滿兩年,申請Google Adsense成為Google的夥伴一份子。
申請條件:
有文章提到部落格要滿半年以上,有效文章達50篇以上。
但這邊有意申請的小夥伴,如果有幾十篇文章,就建議申請看看。(看Google回覆什麼~)

在瀏覽器輸入 site:https//{your site domain} 看看自己的網站在Google上是否能被搜尋到~
可搜尋本部落格 sitemap.xml or robots.txt 關鍵字參考

Google Adsense 使用 Gmail登入
1.先將網站domain輸入並等待審核
2.將程式碼複製貼上 source\_data\head.njk 該檔案

code example:
<script data-ad-client="ca-pub-xxxxxxxxxxxxxxx" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Use For Hexo8 Version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
審核通過後,會寄信通知可以開始啟用
1.新增ads.txt到網站根目錄(該檔案可在Google adsense後台下載),若新增成功可在 https://{your site domain}/ads.txt 看到自己的資訊
2.選擇左邊側邊列 -> 按廣告單元 -> 建立多媒體廣告(需為廣告單元命名) -> 下方會出現一行廣告單元 -> 後面有取得程式碼按鈕
會出現以下:
將廣告單元程式碼複製並貼到網頁的 <body></body> 代碼之間
在您要顯示廣告的位置加入這段程式碼。所有網頁上的每一個廣告單元都需要完成這項操作。

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxx"
crossorigin="anonymous"></script>
<!-- 廣告單元名稱 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxxxxxxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

3.將上述程式碼貼上
source\_data\sidebar.njk
source\_data\post-meta.njk
source\_data\post-body-end.njk

4.部署
hexo clean
hexo g -d

5.對網站右鍵 -> 檢視網頁原始碼 -> 搜尋data-ad-slot="xxxxxxxxxxxxxxx" 確認有沒有部署成功

6.修改 themes\next\_config.yml
搜尋 custom_file_path

sidebar: source/_data/sidebar.njk
postMeta: source/_data/post-meta.njk
postBodyEnd: source/_data/post-body-end.njk
開啟

7.大約等待一小時後確認網站有沒有出現廣告