Developer forum

Forum » Templates » Canonical link in meta is being added when URL contains a querystring parameter

Canonical link in meta is being added when URL contains a querystring parameter

Mikkel Toustrup Olsen
Reply

Hi,

I have a rather weird scenario.

I'm running a DW 9.3.10.

For testing purposes I've disabled the two checkmarks within Web/HTTP -> Customized URLS regarding canonical links in meta. One in the Ecommerce group and another in the Meta group.

When I render a product group url without any querystring parameters there is no <link rel="canonical" href="url" /> in the <head> tag which is fine.

Though, when I add a querystring parameter to the URL a canonical is appended to the <head> tag 

I tried to come about this by utilizing a PageLoadedObserver.

However, the Meta tags within the loaded args always, with and without a query string parameter added to the URL, contains 4 tags: Description, Basehref, Keywords and Generator. No canonical property here to set or manipulate.

I did find the MetaCanonical property on the Pageobject on the pageview, however this is empty which is correct in my current scenario.

Am I going about this the wrong way or am I missing something?

BR

Mikkel 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Well, you missed a lot of upgrades which you should REALLLY do first.

Secondly, the PageLoadedObserver is one of the first things that happens on the pageview - right when it is instantiated. So metatags are not done yet as modules will update them, i.e. the catalog. Modules run on Output.

I think the best notification is the Standard.Page.OnOutput notification.

Also ensure you have not set the canonical checkbox on the product catalog settings - see dump.

BR Nicolai

Capture.PNG
Votes for this answer: 1
 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

You can tell Dynamicweb to not inject any meta tags by setting disableparsing to true in your page layout template (or master).

You will then have to insert any meta tags explicitly (if you need them), e.g. description and keywords.

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
<!DOCTYPE html>
<html>
<head data-settings="disableparsing:true">
    <meta charset="utf-8" />
    <title></title>
 
    @{
        var metaDescription = @GetValue("Meta.Description");
        var metaKeywords = @GetValue("Meta.Keywords");
    }
    <meta name="description" content="@metaDescription" />
    <meta name="keywords" content="@metaKeywords" />
</head>
<body>
    
</body>
</html>
 
Mikkel Toustrup Olsen
Reply

Hi Morten,

I already tried disabling parsing as you mention, however the ajax cart functionality stops working when enabled.

The customer is running a wrap solution. I'll try Nicolai's suggestions and give a feedback if I find a solution.

Thanks

/Mikkel

 
Mikkel Toustrup Olsen
Reply

Hi Nicolai,

The checkbox seems to be the way to go.

/Mikkel

 

You must be logged in to post in the forum