timlrx / tailwind-nextjs-starter-blog

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.
https://tailwind-nextjs-starter-blog.vercel.app/
MIT License
8.84k stars 2.05k forks source link

How can we add adsense code to header #626

Closed mandeepsng closed 1 year ago

mandeepsng commented 1 year ago

Is your feature request related to a problem? Please describe.

this is my adsense code <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxx" crossorigin="anonymous"></script> need to add into header

How can I do that I tried this but not working <Script id="Adsense-id" async="true" onError={(e) => { console.error("Script failed to load", e);}} strategy="afterInteractive" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxx" crossorigin="anonymous" />

Abinaskarki commented 1 year ago

were you able to get adsense code working?

Abinaskarki commented 1 year ago

Hi Mandeep, this issue will get resolved by adding the script to the Head of _document.tsx file in pages folder.

Also, it is better to add ads.txt file with adsense credentials you get from Google Adsense in the public folder.

chandikaRT commented 1 year ago

Hello! Can someone help me out with this, should I create a new _document.tsx in a new folder called pages and then add the script?