Best place to add site-wide chat widget?

Total Grav newbie here, but loving the CMS as I learn more and more about it. Can’t wait until the Admin control panel plug-in :slight_smile:

I am exploring adding a chat widget to my Grav site, and the widget instructions state “…Copy the following script and insert it into your website’s HTML source code between the tags.
This code must be inserted into every page”.

Would there be any best practice about how this is best done with Grav?

Thanks very much,

Couple of options:

  1. Add it directly into the templates/base.html.twig of your theme. See the blog post about extending base theme if you plan on doing this.

  2. Create as simple plugin to add your JS/CSS dynamically to Grav via the assets object. Look at anchors plugin as a good example of how to do this. It only takes a simple plugin to do, and then can be easily published/released and used by others.

Preferred approach is #2 :slight_smile:

Thanks very much. I’ve been able to do #1, but with the minor change that the base.html.twig file for the Antimatter theme I updated was at templates/partials/base.html.twig

Works like a charm! Very clear instructions with the Theme inheritance post as well.


Ah yes, that missing partials dir was a typo on my part.

No problem, I really appreciate the help!