Extend [gatsby-plugin-canonical-urls] for pages with multiple paths #32534
Unanswered
nboliver
asked this question in
Ideas / Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In the GitHub description for this plugin it says: "could possibly be extended to help with when sites add multiple paths to the same page."
With ecommerce projects, one common request is contextual product paths:
/products/smooth-espresso
(canonical)/collections/whole-bean-coffee/products/smooth-espresso
/collections/featured/products/smooth-espresso
These are all the same product page, but the link is contextual depending on whether a user has navigated via a collection page, or directly. This allows setup of contextual breadcrumbs to navigate back to the collection, or to "all products" in the case of the canonical.
I have extended the gatsby-plugin-canonical-urls plugin as a local plugin, and am wondering if there is interest in bringing this work into the official plugin?
My approach was to add an array of paths as regex patterns to the plugin options, like so:
The plugin would then replace
/collections/whole-bean-coffee/products/smooth-espresso
with/products/smooth-espresso
set as the canonical url.Beta Was this translation helpful? Give feedback.
All reactions