Skip to content

canonical url #13

Closed Answered by daveaglick
Arhell asked this question in Q&A
Jun 25, 2020 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Sure! If you call IDocument.GetLink(true) (or IExecutionContext.GetLink(document, true)) it'll produce a link to the current document that includes the Host setting.

For example, to add the canonical link to a Razor page or layout you'd write:

<link rel="canonical" href="@Document.GetLink(true)">

It's up to the theme or layout to add this and I've added it to the CleanBlog theme.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Arhell
Comment options

@daveaglick
Comment options

@Arhell
Comment options

@daveaglick
Comment options

@Arhell
Comment options

Answer selected by Arhell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #13 on August 28, 2020 12:28.