Reputation: 31
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
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
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