Streaming live at 10am (PST)

Canonical Link with CMS-Pages


#1

Hey Community,

is there a way to give CMS pages a canonical?
I´ve found this in the forum, but it doesn´t worked.

I´ve tried this (see screenshot) with a non cms page and it worked pretty well, but how can I get the same result with cms without adding an additional field, than we already have 59 items in use and I would like to avoid taking the last item for this.

Greetings,
Maurice
image


#2

It is possible! You need to add a field in the collection for the canonical link. Then add the URL for the page in the collection. Finally you can dynamically add the canonical link in the page settings for your CMS page like this:

Hope this helps!


#3

Thank you for your reply @LJB.

I know that I could solve it by adding a CMS field with the canonical, but we have only one field left in our collection and I really would try to avoid taking the last item. Also its really static if paste the exactly URL in this field.

I hoped that there is a function like get path or so.

Greetings,
Maurice


#4

Is there really no other solution?


#5

Does anyone know how to extend this custom code with some logical javascript operators?

I would like to do the following:

Set up CMS with “Canonical” field.
In custom code.

  1. If “Canonical” field is empty set canonical URL to current url.

  2. If “Canonical” field is not empty set Canonical URL to “Canonical”


#6

I had the same problem where I wanted to be able to choose whether a canonical attribute would be added to my article links.

The following is modified from @bart 's answer to a similar question from a different forum post - Conditional canonical link in head custom code

I created a switch on our blog collection for syndicated content. When you turn it on, then a link is created in the head with canonical attribute. It takes the potential human error out of creating a link every time we have a syndicated blog article.

15