# vuepress-plugin-google-adsense

Google adsense plugin for vuepress

Use google automatic advertisement for your vuepress site. (Follow Google Ad Code Implementation Guide)

npm download GitHub license

# Install

yarn add -D vuepress-plugin-google-adsense
# OR
# npm install -D vuepress-plugin-google-adsense

# Usage

module.exports = {
  plugins: [
    [
      "vuepress-plugin-google-adsense",
      {
        ad_client: "ca-pub-2245427233262012" // replace it with your ad_client
      }
    ]
  ]
};

More Info: Using a Plugin

If you don't have a google adsense account, you need register one here.

If you pass, google adsense will give you a script like this.

<script
  data-ad-client="ca-pub-2245427233262012"
  async
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
></script>

# Other method

In fact, when this plugin was developed, Google's automatic adsense code was not as simple as it is now.

And now, you can just insert the following code in config.js instead of this plugin.

module.exports = {
  head: [
    [
      "script",
      {
        "data-ad-client": "ca-pub-2245427233262012",
        async: true,
        src: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
      }
    ]
  ]
};

Config Reference | Vupress

One advantage of plugin is that it can decide whether to show by ctx.isProd.

# Options

# ad_client

  • Type: string
  • Default: undefined

Provide the Google Adsense ID to enable integration.

Made with ❤️ by Ahmad Mostafa - @z3by