Rene Morgan
Rene Morgan

Reputation: 31

How to implement Google Adsense on VuePress?

Is there a way to easily implement Google Adsense in VuePress? The resources I've found only provides a 'how-to' for Vue only.

Upvotes: 3

Views: 939

Answers (2)

Adarsh Madrecha
Adarsh Madrecha

Reputation: 7896

If you don't want to modify the config directly, there is a plugin for using Google Adsense

https://www.npmjs.com/package/vuepress-plugin-google-adsense

module.exports = {
  plugins: [
    [
      'vuepress-plugin-google-adsense',
      {
        'google_ad_client': '', // ca-pub-0000000000000000
        'enable_page_level_ads': true
      }
    ]
  ]
}

Upvotes: 0

Aveek Saha
Aveek Saha

Reputation: 121

You can add the following lines to your config.js file

head: [
    ['script', { src: "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" }],
    ['script', {}, 
    '(adsbygoogle = window.adsbygoogle || []).push({  google_ad_client: <your code here>,  enable_page_level_ads: true });'],
],

This will add the code inside your head tag.

Upvotes: 4

Related Questions