Automad allows you to inject custom HTML markup and JavaScript code into your site either globally or on individual pages. This capability enables seamless integration with third-party services such as analytics platforms and commenting systems.
To apply customizations site-wide, navigate to Global Data and Files → Customizations. Page-level customizations can likewise be applied and automatically merged with their global counterparts.
Integration Types
Depending on the content or script you want to integrate, you need to choose the right location for code injection. The following fields are available for adding custom code:
- Custom HTML in the head element — for meta tags, cookie consent wrappers, and conditionally loaded JavaScript or CSS files
- Custom HTML before the closing body tag — for widgets, embed codes and tracking snippets that need the page content to be loaded first, as well as
<script>tags that load external files at the end of the page - Custom JavaScript in the head element — for plain JavaScript that has to run before the page content is loaded, such as configuration objects that third-party scripts expect
- Custom JavaScript before the closing body tag — for plain JavaScript that accesses elements on the page
The code of both JavaScript fields is wrapped in a <script> element automatically, so don't add the tags yourself. To load an external script file, use one of the HTML fields instead. The Customizations tab also has a field for custom CSS, which is explained in Custom Styles.
GDPR Compliance
When integrating third-party services that set cookies for tracking user data, ensure your implementation complies with GDPR regulations. Refer to the Cookie Banner guide for instructions on implementing GDPR-compliant script integration.