Generates canonical URL meta tags for the HTML head section.
Canonical URLs help prevent duplicate content issues by telling search engines which URL is the "official" version of a page. Also supports hreflang for international SEO.
import { canonical } from '@raven-js/beak/seo';// Basic canonical URLconst tags = canonical({ domain: 'example.com', path: '/my-page'});// Output:// <link rel="canonical" href="https://example.com/my-page" />// Canonical with hreflangconst hreflangTags = canonical({ domain: 'example.com', path: '/my-page', hreflang: 'en-US'});// Output:// <link rel="canonical" href="https://example.com/my-page" hreflang="en-US" />// Canonical for mobileconst mobileTags = canonical({ domain: 'example.com', path: '/my-page', media: 'only screen and (max-width: 640px)'});// Output:// <link rel="canonical" href="https://example.com/my-page" media="only screen and (max-width: 640px)" /> Copy
import { canonical } from '@raven-js/beak/seo';// Basic canonical URLconst tags = canonical({ domain: 'example.com', path: '/my-page'});// Output:// <link rel="canonical" href="https://example.com/my-page" />// Canonical with hreflangconst hreflangTags = canonical({ domain: 'example.com', path: '/my-page', hreflang: 'en-US'});// Output:// <link rel="canonical" href="https://example.com/my-page" hreflang="en-US" />// Canonical for mobileconst mobileTags = canonical({ domain: 'example.com', path: '/my-page', media: 'only screen and (max-width: 640px)'});// Output:// <link rel="canonical" href="https://example.com/my-page" media="only screen and (max-width: 640px)" />
Configuration object for canonical tags
The generated canonical meta tags as an HTML string
Generates canonical URL meta tags for the HTML head section.
Canonical URLs help prevent duplicate content issues by telling search engines which URL is the "official" version of a page. Also supports hreflang for international SEO.
Example