How to Set Up Google AdSense and Add ads.txt to WordPress Without a Plugin

By Author Jonathan David

In this PLEM Academy lesson, I connect MathMonthly.com to Google AdSense and upload an ads.txt file through my hosting dashboard. I’m setting up ads for selected public posts while keeping the main site and member lesson library ad-free.

Connect your WordPress site to AdSense

I add my domain in AdSense, copy the verification code into my theme’s header scripts field alongside the existing MathJax code, and return to AdSense to verify the site and request a review.

Upload ads.txt through cPanel

  1. Copy the exact ads.txt entry shown for your site in AdSense.
  2. Paste it into a plain-text document and save it as ads.txt.
  3. In cPanel File Manager, upload it to your domain’s document root. In my setup, that folder is public_html. If your hosting account serves several sites, use the document root assigned to the domain you’re connecting.
  4. Open yourdomain.com/ads.txt in a browser and confirm that the page displays the entry you uploaded.

Check your site after editing the header

During the walkthrough, one of my lesson accordions looked compressed after I edited the header. I checked the MathJax snippet and retested the page. The layout returned to normal during troubleshooting.

Explore PLEM Academy at Math Monthly

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x