Sites: Outputting the canonical URL for a page

espanae's Avatar

espanae

29 Mar, 2016 09:00 PM

Hello,

Is there a way to generate canonical URLs for pages in different Sites, using a single Velocity format?

The technique recommended in this post works for most of our pages, but because the paths generated are relative to the containing Site, it doesn't work for Sites that map to website subfolders.

Ie, site://magazine/index generates:
<link href="https://www.union.edu" rel="canonical"/>

instead of:
<link href="https://www.union.edu/magazine" rel="canonical"/>

Ideally, I would replace the Velocity script's hard-coded domain with the current page's Site URL (see attached). Is that possible in Cascade 7.12.4? If not, I'm open to suggestions.

Thanks,
Erik

  1. 1 Posted by Ryan Griffith on 30 Mar, 2016 01:00 PM

    Ryan Griffith's Avatar

    Hi Erik,

    Unfortunately, it is not currently possible to obtain the Site's URL within a Format (or Index Block). We do have a related suggestion for this on our Idea Exchange. I highly recommend voting this up if you have not already.

    In the meantime, the workaround we have seen clients take is to name the Site the same as the URL. In cases where the URL contains a subfolder, the convention is to use a token such as + to replace the /, and replace that token using a Format when the link is generated. You could probably adapt the same solution here but also add a translation to replace the token.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by espanae on 30 Mar, 2016 03:36 PM

    espanae's Avatar

    Thanks for the quick response, Ryan.

    Employing the Site name in my Velocity script, by way of the $currentPageSiteName variable, proved an effective workaround. I also voted for the related suggestion on the Idea exchange.

    You may close this discussion,
    Erik

  3. 3 Posted by Ryan Griffith on 30 Mar, 2016 03:57 PM

    Ryan Griffith's Avatar

    Not a problem at all, Erik. I am glad to hear you were able to come up with a solution. And thank you for contributing to our Idea Exchange!

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 30 Mar, 2016 03:57 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM