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">
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With