-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show Canonical URL of posts in search #287
Comments
This is very likely going to come down to what information is being indexed as well as what indexed content on a given object is being used for the generated link in either the Autocomplete or the InstantSearch experiences. We'd need to get the correct permalinks added to a given post's index as well as customize the template in question. If you want/need, I can point you to the correct documentation for both of those parts, and help answer some questions about that as needed. The wiki is a pretty good starting area https://github.com/WebDevStudios/wp-search-with-algolia/wiki for example the custom attributes section https://github.com/WebDevStudios/wp-search-with-algolia/wiki/Custom-Attributes |
@tw2113 Thank you. Can you share a code snippets for use to resolve this? |
Are you needing this for the Autocomplete integration or the Instantsearch? The first code snippet at this page would be used for Autocomplete with the You'd want to change it to At that point, you'll need to customize the template file for the appropriate usage, eg Autocomplete or Instantsearch, and have it reference that new property for the link, and using the canonical url stored in that property. For example... https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/templates/autocomplete.php#L19-L33 On line 22 at the link above, we have the template for Autocomplete and the You can read about template customization at https://github.com/WebDevStudios/wp-search-with-algolia/wiki/Customize-Templates |
Did you ever make any headway here @yogeshbeniwal |
@tw2113 No haven't. I was hoping this functionality will be available out of box. |
Admittedly, we aim to keep the WP Search with Algolia as agnostic as possible, but that also means that we're taking a less out-of-box approach. This allows for others to add in details for their specific site needs, rather than us trying to make assumptions and result in making site owners have to somehow undo those decisions, because they don't apply to their use cases. I can also say that we're working on a Pro addon for WP Search with Algolia, but that won't be a free one, and some of the features intended for that Pro addon are SEO based. This is something that I could get added to feature ideas if you'd like that, or if you'd prefer some potential help with overriding on your own. |
So I'm definitely seeing the behavior described, but I'm also not seeing any great way, so far, to actually get the generated canonical URL, outside of the value manually saved in the |
Doing some more testing with this this morning. I'm DECENTLY certain that when not using the meta field in the Advanced panel, Algolia is receiving the canonical URL. Based on some research and some asking around, I believe Yoast makes use of That said, the Advanced panel needs some extra finesse. Something like the following looks like it's working from my testing. ORIGINAL:
New August 3rd 2023:
I think this would cover both potential sources, between the meta and the usage of EDIT: Yoast SEO folks pointed me to EDIT 2: After testing, I have updated the snippet above to make use of the Yoast-provided version. Bonus: If you want to get a term canonical URL, you can use |
Describe the bug
When posts are assigned multiple categories and permalink is set as /%category%/%postname%/, same post is accessible from multiple url, e.g. [Domain]/Category1/post-slug and [Domain]/Category2/Child2/post-slug. When Yoast SEO plugin is used and setting up Child2 as primary category, a canonical URL is set for all other URLs pointing to URL with primary category f.g. [Domain]/Category2/Child2/post-slug.
Currently Algolio search shows URL in search as [Domain]/Category1/post-slug instead of [Domain]/Category2/Child2/post-slug.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Search shall take canonical URLs in account and direct user to [Domain]/Category2/Child2/post-slug instead of [Domain]/Category1/post-slug
The text was updated successfully, but these errors were encountered: