How To Add Google AdSense To Hugo + PaperMod Website

Cover Image for How To Add Google AdSense To Hugo + PaperMod Website
Image generated by DALLE
Visit pacebits.com for my recent projects

Goal

Add Google AdSense to the website to monetize it 💸💸

Prerequisites

  1. Website built with Hugo and PaperMod theme
  2. Google AdSense account

Steps

  1. Add the website to Google AdSense account.
  2. [Optional] Config Ads setting in Google AdSense.
  3. Get AdSense code snippet, which should be similar to the following:
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=xxxxxxxxxx"
        crossorigin="anonymous"></script>
    
  4. Create file layouts/partials/extend_head.html in the code of the website, if it doesn't exist.
    • Note: the content of this file will be added to <head>...</head> of the page by PaperMod.
  5. Paste "AdSense code snippet" into layouts/partials/extend_head.html.
  6. Create file static/ads.txt in the code of the website, if it doesn't exist.
  7. Paste "Ads.txt snippet" from AdSense into static/ads.txt
  8. Verify the change locally, and deploy it.
  9. Submit review request in Google Adsense, and wait for the processing.

DONE!