出现问题

已在hexo的butterfly主题配置文件中添加google adsense的客户号,但是adsense审核提示失败,如何解决?

Google Adsense审核失败通知

hexo的配置:

1
2
3
4
5
6
7
# Google Adsense (谷歌廣告)
google_adsense:
enable: true
auto_ads: true
js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
client: ca-pub-1711515749423877
enable_page_level_ads: true

通过查看页面元素发现,静态页面中已经生成了adsense的代码:

1
2
3
4
<script async="async" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: 'ca-pub-1711515749423877',
enable_page_level_ads: 'true'
});</script><

对比发现,这段js和接入google adsense的code不一致:

1
2
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1711515749423877"
crossorigin="anonymous"></script>

解决方法

关掉hexo的中google_adsense的配置,不让butterfly生成代码:

1
2
3
4
5
6
7
# Google Adsense (谷歌廣告)
google_adsense:
enable: false
auto_ads: true
js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
client: ca-pub-1711515749423877
enable_page_level_ads: true

在配置文件中搜索inject,做如下配置:

1
2
3
4
5
6
# Inject
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
inject:
head:
- <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1711515749423877" crossorigin="anonymous"></script>

注意:以上所说的hexo配置指的是butterfly主题的配置文件。
另外:记得把google clientId更换为你自己的Google Adsense clientId。