2

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

2 Answers 2

3

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.

0

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
      }
    ]
  ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.