adsense - fitizens/hugo-modules GitHub Wiki

Google Adsense

Install Module

Add the following code to your module list in the config/_default/module.toml file.

[imports](/fitizens/hugo-modules/wiki/imports)
path = "github.com/gethugothemes/hugo-modules/adsense"

Implementation

Add this configuration to your config/_default/params.toml file.

# google adsense, see https://www.google.com/adsense/
google_adsense = "" # example: ca-pub-XXXXXXXXXX

Call it, as a partial in your script.html file.

<!-- google adsense -->
{{ partialCached "adsense-script.html" . }}

If you want to use it in some specific location, then call this partial there.

{{ partial "adsense" (dict "Slot" "YOUR_SLOT_ID" "Format" "auto") }}

If you want to use it in the markdown file, then call this shortcode in the markdown file.

{{< adsense slot="YOUR_SLOT_ID" format="auto" >}}