With AMP HTML, is it legitimate to set the canonical href attribute of a pound (#) link?

Can I set a canonical link to the pound symbol as shown below, or do I need to enter the physical name of the page?

<link rel="canonical" href="#">

When testing this parameter, the pound does not generate a validation error (ala # development = 1). In my scenario, a page using this layout file will not have an alternate version of β€œplain HTML”. The only version will be the HTML AMP version.

For added context, I'm experimenting with an MVC site that will use AMP HTML. To keep my layout file simple, I would rather use the pound symbol rather than extract the name of the child page and apply it to the href attribute. I know how to apply a URL to a partial view using code as follows:

<link rel="canonical" href="@HttpContext.Current.Request.Url.AbsoluteUri">

I'm just curious if I end up AMP HTML instead of the pound symbol. Thanks.

+4
source share
2 answers

From the documentation :

Necessary markup

AMP HTML documents MUST :

  • <link rel="canonical" href="$SOME_URL" /> , HTML- HTML- AMP document , HTML- .

href="#" , AMP.

+7

, . "#" URL- , , , cdn.ampproject.org, URL . URL <link rel=canonical href="URL">.

+2

Source: https://habr.com/ru/post/1614164/


All Articles