Distributor: Option or hook to manage canonical URL

Created on 1 Feb 2019  ·  11Comments  ·  Source: 10up/distributor

Currently, Distributor plugin is modifying canonical URL of distributed post and pointing to original website.
We would like to stop this behaviors and the only way to do if with current code - remove added filters.

https://github.com/10up/distributor/blob/27c92e65fbca30c947900f223ec797811ffed785/includes/classes/ExternalConnections/WordPressExternalConnection.php#L947

Will you consider an option from admin to manage this functionality or a flag, that will be passed through filter?

Documentation enhancement good first issue

All 11 comments

@arsendovlatyan thanks for the input, it's appreciated! Could you describe your use case in a little more detail so we can better plan how we might be able to help address your problem with Distributor?

@jeffpaul thanks for quick reply.
We have e-commerce platform, based on WooCommerce and we are uploading all products to a central website (Hub), and using Distributor, pushing this products to other websites (Spokes).
Because the Hub is password-protected, it doesn't make sense to point canonical URLs back to Hub from Spokes.

@jeffpaul Sorry, do you need more information? I can't send PR if you would like.

@arsendovlatyan am I correct in understanding that you're asking for a way when you distribute from your Hub that the distributed posts do NOT link back to the original by default or otherwise have an option to disable the linkage?

@jeffpaul exactly, an option or a filter that will allow us to manage this behavior.

Hey @jeffpaul
Sorry, if it's possible, would to hear your feedback, to be able to move ahead or close this issue.
I think we can add another option and call it maybe Override canonical URL, which will be ON by default, but I'm not sure if this functionality will be useful for others.
If it's useless or can confuse users, maybe add a filter like dt_canonicalize_front_end to be able manage this behavior ?
Can send a PR if any of this options works for you.

Thank you very much!

Hey @arsendovlatyan Thanks for opening this issue. Jumping in for Jeff who has been out and too swamped to get back to you yet.

We would like to stop this behaviors and the only way to do if with current code - remove added filters.

Removing the filter is the recommended way to disable this behavior; this is a common pattern in WordPress and part of the reason we always use a named callback you can remove vs. an anonymous function.

Another potential option you could use would be adding a later hook on get_canonical_url and returning your own URL.

An additional filter doesn't seem necessary unless I am misunderstanding how you want to use it.

Will you consider an option from admin to manage this functionality or a flag, that will be passed through filter?

An admin option feels like it has the potential for confusing users. In the vast majority of cases, sites will want to have canonical links back to their original content from the distributed copies because of the potential SEO implications; this article summarizes those pretty well: https://moz.com/learn/seo/duplicate-content.

You bring up a good point that some users may be surprised or not want this behavior. It would be great to improve the documentation around this feature - how it works and how to disable it. Searching the docs I don't see any mention of the canonical URL altering (docs need improvement in general). Perhaps a paragraph in the readme issues or developer section (https://github.com/10up/distributor/blob/develop/README.md)? A PR for that would be welcome!

Just something that may be of use here - I had a similar query and Adam gave me some great feedback. https://github.com/10up/distributor/issues/135

@adamsilverstein thank you very much, completely agree with you!

@jeffpaul Just sent a PR for doc update, if you think it worth's to have own section in read.me, please review, otherwise, we can close this issue.

Thanks for assistance

@jeffpaul If you don't mind, I'll close this issue ))

@arsendovlatyan thanks for catching that, I've updated this to note it landed in v1.5.0!

Was this page helpful?
0 / 5 - 0 ratings