add google adsense into hexo blog in next theme

build a new adsense template under next theme in layout/_custom

1
themes/next/layout/_custom/google_adsense.ejs

put the google adsense codes into google_adsense.ejs

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

add following codes in _layout.swig under theme folder

1
2
3
<!-- Google AdSense start -->
{% include '_custom/google_adsense.ejs' %}
<!-- Google AdSense end -->

generate web page and check source file to see the google code in there


more on searchfor.space