1

I'm hoping this is an easy one. The CanonicalUrl rendering in the Metadata Partial design isn't honoring our https settings for the website.

Instead, it always shows http in the canonical link for every page on the site.

Am I missing a setting somewhere? All sites are set to use the https protocol. Before I start investigating the dll I figured I would ask! Thanks!

2 Answers 2

1

Canonical URL is a part of Metadata Snippet Layout.cshtml

The metadata partial design is different from the regular partial design because it uses a metadata layout (Layouts/Foundation/Experience Accelerator/Presentation/Metadata Layout). This layout is bound to /Views/SXA/Metadata Snippet Layout.cshtml and contains the following placeholders:

  • head

  • body-top

  • body-bottom

CanonicalURL is a part of the head placeholder and Renders the canonical URL of the page. It's been part of Sitecore.XA.Feature.SiteMetadata.dll

There is a CanonicalUrlRepository and it has a method called GetModel. Here, you can find how it prepares URL and uses url.Scheme from the current request URL HttpContext.Current.Request.Url.

public CanonicalUrlModel GetModel(Item item)
    {
        ItemUrlBuilderOptions urlOptions = UrlOptionsProvider.GetUrlOptions();
        string text = Context.Site.SiteInfo.ResolveTargetHostName();
        Uri url = HttpContext.Current.Request.Url;
        string itemUrl = LinkManager.GetItemUrl(item, urlOptions);
        return new CanonicalUrlModel
        {
            Url = url.Scheme + Uri.SchemeDelimiter + text + itemUrl
        };
    }

Hope it helps!

0

Turns out it’s by design. Nginx ingress handles TLS termination, so the pods listen on port 80 (http). Will add my own module. Thanks for the response! Helped to see the schema coming in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.