How to inject HTML code in the head only on home and post pages

Hi, I wanted to know if there is a way to inject an HTML code to the <head> section, only in the home page and post pages?

Thank you.

I believe that what you want to do is add code to the script that checks the URL and fires only when it’s on the pages you’re interested in.

1 Like

The code is Adsense auto ads in the header. Should I then create a conditional statement in javasciprt and rewrite that code to insert the javascript then?

Yes, you may try to read the Developer’s guide to Discourse Themes. For Adsense I recommand you to try Offical Adversting Plugin if you didn’t.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.