October CMS resources and help articles

Simple and to the point. Optimized by the community.

How to add a canonical link to your layout in twig

7
by mjauvin, last modified on November 14th, 2019

Add this to the section of your layout:

<link rel="canonical" href="{{ url_current() | lower }}" />

or

<link rel="canonical" href="{{ this.page.id | page }}" />

Discussion

2 comments

0
drmzio
Post on November 20th, 2019 6:55 AM

Didn't know about the url_current() function, thanks!

0
NEXTMARVEL
Post on September 29th, 2021 7:47 PM

This is for wordpress as well? I am actively looking for a twig solution for printing this kind of canonical line. Thank you!

We use cookies to measure the performance of this website. Do you want to accept these cookies?