GitHub

How to implement GDPR cookie popup support in your theme?

If you wish to add support for the GDPR cookie popup to your Publii theme, you will need to make a few simple but necessary changes to your theme:

  1. Add the {{{ publiiFooter }}} help before the </body> tag in your theme's code; if you're using a default Publii theme as a base then you can skip this step, but you will need to make sure that the theme is updated to the latest version.
  2. Search for and catalogue any scripts which will need to be consented to run by your users, and separate them into groups depending on their specific function e.g. analytical, marketing etc...
  3. For each script that should be blocked by default (before consent is given), add a type attribute with the {{ gdprScriptBlocker "group-name" }} value. For example, if you want to block a script from the analytical group, you would use:
    <script src="analytics.js" type="{{ gdprScriptBlocker "analytical"}}"></script>
  4. Once you've added this to all the relevant scripts, create a new post in Publii that will act as your Privacy Policy page. We recommend making it a hidden post so it does not appear in post listings, only in links from the popup or from links added to your menus.
  5. In the Site Settings section of Publii, open the GDPR tab and enable the Add GDPR cookie banner option. Then, configure the popup content (description, labels etc...) and select your create Privacy Policy page from the list in the Privacy policy page option.
  6. Next, define the script groups which will be managed by the cookie popup. For every script group you can define a group name and an ID. The group name will be seen by users as an available checkbox in the popup, whilst the ID should be the same as the group-name parameter that you set in the {{ gdprScriptBlocker }} helper for that particular group.
  7. (Optional) If you're using the Access the popup as a custom link option, make sure to add a menu item or common website element which can be used as the link to display the GDPR cookie popup; remember that this link should be an anchor.

Your popup is now configured and ready to use.

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.