How to Add a Cookie Policy to Craft CMS

Last updated on October 19, 2026

This guide will walk you through how you can generate and add a Cookie Policy page on your Craft CMS website. A Cookie Policy is a document that provides detailed disclosure about the types of cookies used on a website and their purposes. It can help your website meet transparency requirements under privacy laws such as the GDPR and the ePrivacy Directive.

Prerequisites

  • A CookieYes account (if you don't have one, sign up for free).
  • Admin access to your Craft CMS website.
Note

After you sign up, you will be directed to the installation screens. You can install the cookie banner to support GDPR compliant for your use of cookies. If you prefer to create a cookie policy first, skip the installation and go directly to the CookieYes Dashboard.

  1. Log in to your CookieYes account.
  2. From the top navigation bar, select Legal Policies.
  3. From the Cookie Policy section, click + Generate.
legal_policies_dashboard.png

Step 2. Configure language settings

  • Select your primary language. The chosen language will appear with a checkmark.
  • (Optional) Enable Generate policy in multiple languages to add more languages. This feature is available on Basic, Pro and Ultimate plans.
  • Click Save draft to save your progress or Next to continue.
language_settings

Step 3. Add about cookies details

In the About cookies section, edit the heading and description to explain what cookies are and why your website uses them. You can keep the default text or edit it to match your website’s practices.

about_cookies

Step 4. Add use of cookies details

In the Use of cookies section, describe how your website uses cookies (for example, functionality, analytics, performance, or advertising). You can keep the default text or update it for accuracy.

When ready, click Preview cookie policy to review the formatting and tone before proceeding.

use_of_cookies

Step 5. Review and edit types of cookies

In the Types of cookies section, you will see a list of cookies from your most recent website scan. If needed, you can refresh the list by clicking Scan again to capture any new cookies. The cookies are organised into categories such as Necessary, Functional, Analytics, Performance and Advertisement. Review each entry carefully to verify the cookie name, duration, and purpose for accuracy.

types_of_cookies

In the Cookie preferences section, keep the default heading (“Manage cookie preferences”) and description, or update them with instructions specific to your users. Set the Effective Date for the cookie policy. Preview the policy to verify the details and when confirmed, click Generate cookie policy to generate the policy.

set_cookie_preferences
Note

The Revisit consent widget enables your website visitors to manage their cookie preferences. You can remove the code in the field if you don’t want a widget to be displayed. For more details, refer to the guide.

After you generate your cookie policy, review the preview in each selected language. Click Add policy to site to open a modal with ways to add your cookie policy.

add_policy_to_site

Adds the cookie policy using your existing cookie banner script. The published policy updates automatically whenever you make changes in CookieYes.

Step 1: Select One-click install

In the modal, select One-click install.

Step 2: Create a policy page in Craft CMS

  1. Log in to your Craft CMS website.
  2. Go to Settings > Fields, then click + New field.add-new-field-craft-cms.png
  3. Enter Body HTML in Name and bodyHtml in Handle. In Field Type, select Plain Text, then click Save.create-new-field-crft-cms.png
  4. Go to Settings > Sections, then click + New section.add-new-section.png
  5. Enter Cookie Policy in Name and cookiePolicy in Handle. In Section Type, select Single.
  6. Click + Create and add an entry type named Cookie Policy, then click Save.new-section-craft-cms.png
  7. In the Sections list, select Cookie Policy, then select its entry type.select-entry-type.png
  8. In Field Layout, drag in the Body HTML field, then click Save.drag-body-html.png
  9. Copy the URL of the cookie policy page and paste it into the CookieYes web app.page-url-cookie-policy.png

Step 3: Embed the policy code

  1. In the left-hand menu, click Entries, then select the Cookie Policy entry.select-cp-entry.png
  2. Paste <div id="cky-auto-cookie-policy"></div> into Body HTML, then click Save.paste-code-craft-cms.png

Step 4: Publish and verify

1. Return to the CookieYes web app.

2. Click Publish cookie policy.

publish-policy.png

3. Open the live cookie policy page on your Craft CMS website.

Your cookie policy page is now live on your Craft CMS website. You can link the cookie policy in your website footer, and within your cookie banner so visitors can read it before they give consent.

Option 2: Hosted URL

Displays your cookie policy through a hosted link. The policy updates automatically whenever you make changes in CookieYes.

Step 1: Copy the hosted URL

  1. In the modal, select Hosted URL.
  2. Click Copy URL.
hosted-url.png

By default, the policy uses the visitor’s browser language. To set a specific language, add its code to the end of the URL. For example, /fr for French: https://legal.policygenerators.com/cookie-policy/xxxxxxxxxxxxxxxxx/fr

Tip

If someone else manages your website, click Send URL to a teammate to share the link with them.

These steps add the link to your site footer, though you can place it anywhere on your site.

  1. In your Craft CMS project files, open the template that contains your footer, such as templates/_partials/footer.twig.
  2. Add the following line where you want the link to appear. Replace HOSTED_URL with the URL you copied.
    <a href="HOSTED_URL">Cookie Policy</a>
  3. Save the file and deploy the change to your live site.

Option 3: Code snippet

Adds the cookie policy using a JavaScript snippet. The published policy updates automatically whenever you make changes in CookieYes.

Step 1: Copy the code snippet

  1. In the modal, select Code snippet.
  2. Click Copy code.
copy-code-cs.png
Tip: If someone else manages your website, click Send code to a teammate to share the code with them.

Step 2: Create a policy page in Craft CMS

  1. Log in to your Craft CMS website.
  2. Go to Settings > Fields, then click + New field.add-new-field-craft-cms.png
  3. Enter Body HTML in Name and bodyHtml in Handle. In Field Type, select Plain Text, then click Save.create-new-field-crft-cms.png
  4. Go to Settings > Sections, then click + New section.add-new-section.png
  5. Enter Cookie Policy in Name and cookiePolicy in Handle. In Section Type, select Single.
  6. Click + Create and add an entry type named Cookie Policy, then click Save.new-section-craft-cms.png
  7. In the Sections list, select Cookie Policy, then select its entry type.select-entry-type.png
  8. In Field Layout, drag in the Body HTML field, then click Save.drag-body-html.png

Step 3: Embed the policy code

  1. In the left-hand menu, click Entries, then select the Cookie Policy entry.select-cp-entry.png
  2. Paste the JavaScript snippet into Body HTML, then click Save.snippet-cms.png

Option 4: HTML format

Adds the cookie policy as static HTML. You update the page manually whenever the policy changes.

Step 1: Copy the HTML

  1. In the modal, select HTML format.
  2. Select your preferred language.
  3. Click Copy code.
html-format.png
Tip

If someone else manages your website, click Send code to a teammate to share the code with them.

Step 2: Create a policy page in Craft CMS

  1. Log in to your Craft CMS website.
  2. Go to Settings > Fields, then click + New field.add-new-field-craft-cms.png
  3. Enter Body HTML in Name and bodyHtml in Handle. In Field Type, select Plain Text, then click Save.create-new-field-crft-cms.png
  4. Go to Settings > Sections, then click + New section.add-new-section.png
  5. Enter Cookie Policy in Name and cookiePolicy in Handle. In Section Type, select Single.
  6. Click + Create and add an entry type named Cookie Policy, then click Save.new-section-craft-cms.png
  7. In the Sections list, select Cookie Policy, then select its entry type.select-entry-type.png
  8. In Field Layout, drag in the Body HTML field, then click Save.drag-body-html.png

Step 3: Add the HTML

  1. In the left-hand menu, click Entries, then select the Cookie Policy entry.select-cp-entry.png
  2. Paste the HTML into Body HTML, then click Save.html-code-craft-cms.png
Note

To remove the Cookie Policy heading at the top of the page, delete the following line from the HTML code: <h1 class="cookie-policy-h1">Cookie Policy</h1>

Conclusion

Your cookie policy is now live on your Craft CMS website. Link it in your website footer and within your cookie banner so visitors can read it before they give consent. If you used HTML format, update the page whenever you change the policy in CookieYes.

Was this article helpful?

Have more questions?

Reach out to us and we'll answer them.

Contact us