Replies: 4 comments
-
If this is an Astro app using If this is an Analog app (and if the above scope is incorrectly set to astro-angular), then this may be blocked due to an upstream issue: nitrojs/nitro#2052 An unofficial solution would be to modify the document in the constructor, which would be pre-computed for SSG pages at build time. I'm not sure about the SSR pages. |
Beta Was this translation helpful? Give feedback.
-
Got it temporarily solved by adding to // Base URL of your website
const baseUrl = 'https://tapbeep.com';
// Generate the canonical URL based on the route
const canonicalUrl = `${baseUrl}${route.route}`;
// Inject the canonical tag into the <head> section
const canonicalTag = `<link rel="canonical" href="${canonicalUrl}">`;
route.contents = route.contents?.replace('</head>', `${canonicalTag}</head>`); |
Beta Was this translation helpful? Give feedback.
-
Cool, we'll note the workaround for now |
Beta Was this translation helpful? Give feedback.
-
Above shared solutions adds trailing slash to the base url Further modified it to remove trailing slash in case of root URL let _route = route.route;
if (_route === '/') {
_route = '';
}
const canonicalUrl = `${baseUrl}${_route}`; |
Beta Was this translation helpful? Give feedback.
-
Which scope/s are relevant/related to the feature request?
astro-angular
Information
After generating a static site, the URLs are visited using query parameters, which are used to track analytics. However, Google is reporting them as separate URLs.
Can a canonical URL element be added to the root URL during the static build? If not, a feature to do so would be of a great addition.
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions