Hexo blog maupassant theme add Google Adsense ads.

Since settled in Github Page, a long period of time using a minimalist and a bit of art range of children's fexo theme, rather than next theme famous. Later stumbled upon Hexo blog in line with my aesthetic maupassant theme, prepare a good business, but the lack of updated blog of power. New year, I finally decided to introduce Google Adsense, to make their blog look a little mainstream, if we can make some pocket money by the way, of course better. The default paper readers have already registered Adsense account, following only share specific set of steps to facilitate their future reference.

Download specific ad module code from Adsense, note that you download the JavaScript code, and our maupassant using Jade, do not need to write, use an online converter like: html2jade . The latest version has been used in a pug, pug and jade but in fact the same thing.

Open maupassant / _config.yml file in the theme directory, add ad control switch:

      
      
1
      
      
show_ad_post: true

In maupassant / lay large columns  add Google Adsense ads Hexo blog maupassant theme out / _partial / head.pug add code inside:

      
      
1
2
3
4
      
      
if theme. show_ad_post
( Async = '' src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' )
script.
( adsbygoogle = window.adsbygoogle || []). push( {google_ad_client: "ca-pub-XXXXX", enable_page_level_ads: true});

This code is copied down from your Adsense account in the application, which replace ca-pub-XXXXX into their account on the line. But this set is fully let Google determine ad position for us, and sometimes appear chaotic pages, blog readability relatively poor. Consider creating ad slots in Adsense, and then add the code just fine in a particular location, my choice is at the end of the article, add one of the ads above comment.

The first method is to use site deployment of advertising, I wish everybody a lot of attention!

Guess you like

Origin www.cnblogs.com/lijianming180/p/12147472.html