How to add a canonical link to your layout in twig
7
Add this to the section of your layout:
<link rel="canonical" href="{{ url_current() | lower }}" />
or
<link rel="canonical" href="{{ this.page.id | page }}" />
Simple and to the point. Optimized by the community.
Add this to the section of your layout:
<link rel="canonical" href="{{ url_current() | lower }}" />
or
<link rel="canonical" href="{{ this.page.id | page }}" />
Didn't know about the
url_current()
function, thanks!This is for wordpress as well? I am actively looking for a twig solution for printing this kind of canonical line. Thank you!