3

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

4

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.