I want to add a canonical URL to my master page which is coming from the document type. So on my document type I have a node picker where I can select a page from the content tree. I want to render this URL in the head section of my master template. Is this possible?
I've tried many things, the most obvious ones didn't work:
var canonicalUrl = Model.Value("metaCanonical").Url
Thank you for your suggestion, I think we'll go with this solution. We'd need to add the section to every page, but I think it's the only way to get it working. Thanks alot!
Get value from document type in master page
I want to add a canonical URL to my master page which is coming from the document type. So on my document type I have a node picker where I can select a page from the content tree. I want to render this URL in the head section of my master template. Is this possible?
I've tried many things, the most obvious ones didn't work:
Or
I'm aware that the master page can't inherit any specific model, this is what my master template inherits:
Any suggestions as to how I can access the page URL from the node picker? Thanks in advance!
Hi Sjoerd, You can achieve this using standard MVC sections. In the master page place this in the head section:
Then in your tempates which inherits this master page place this:
You can name the section as you wish (not necessary to be "Head").
Mila
Thank you for your suggestion, I think we'll go with this solution. We'd need to add the section to every page, but I think it's the only way to get it working. Thanks alot!
is working on a reply...