TransWikia.com

Create custom field to input canonical url in a page

Craft CMS Asked by GraMas on March 10, 2021

What is the best way of creating a custom field for each page whereby the user can input a URL into a field, which then gets input into a rel=canonical element like the example below.

<link rel="canonical" href="{{URL_FROM_CUSTOM_FIELD}}">

I already have an SEO tab like in the image below, however I am unsure of how to create a custom field inside this tab.

enter image description here

If someone could point me in the right direction, that would be great, as I am very new to the CMS.

One Answer

First, I would recommend looking at the SEOmatic plugin - it does all of this for you, and a whole lot more.

If you want to go it on your own, though, I would just use {{ craft.request.url }} rather than adding your own field. Craft already knows what the URL is.

Answered by Patrick Harrington on March 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP