Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In angular 2 how do you make the canonical tag in the index.html page dynamically change

In angular 2 how do you make the canonical tag in the index.html page dynamic so I can share page urls with social media.

This is it currently:

<link rel="canonical" href="https://mywebsite.co.uk">
like image 917
AngularM Avatar asked Mar 08 '16 13:03

AngularM


People also ask

How do you implement canonical tags?

Canonical tag implementation for SitecoreIdentify your preferred URL for duplicate content. Your preferred URL is the canonical URL. Add a rel="canonical" link from the duplicate pages to the canonical one. Add a self-referencing canonical tag on the canonical page, referencing itself as the canonical page.

What is canonical form in angular?

A canonical tag (AKA “rel canonical”) tells search engines to use the URL defined in the canonical tag to appear in search results. You can refer this guide to find more about the importance of Canonical URL.

Where do you put rel canonical?

Make sure you'd prefer the rel=canonical URL to be displayed in search results (rather than the duplicate URL). Include the rel=canonical link in either the <head> of the page or the HTTP header. Specify no more than one rel=canonical for a page.


1 Answers

This is not possible with angular 2 unless you are using angular universal. Are you using angular universal?

Also this may not be the correct direction. Typically the canonical tags are not for sharing a particular page but are designed to stop search engines from crawling deeper into a particular area of your site.

I think you are looking to adjust the meta tags dynamically for sharing on facebook and twitter. Which in that case you can review this article to find out more information https://moz.com/blog/meta-data-templates-123

like image 94
thomasmeadows Avatar answered Sep 28 '22 04:09

thomasmeadows