algolia / vue-instantsearch

πŸ‘€ Algolia components for building search UIs with Vue.js

Home Page:https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[v3.8.1] AisHierarchicalMenu CreateURL generates different URL when selected vs deselected - can hurt SEO crawlers.

jonathan-bird opened this issue Β· comments

Bug 🐞

What is the current behavior?

When a category is not selected, the URL will be the current category URL (expected), and when you select the category, the URL for that category then changes to the URL of the parent, to de-select that category and go back to the parent category. This may be nice behaviour for the user (possibly - may be nice to have as a boolean flag though), however it would cause issues with Google/SEO crawlers as it creates inconsistencies with what a page URL should actually be.

If you think about how an SEO crawler works, they go through every URL and match up words to URLs and work out backlinks etc. This can be confusing for a crawler if it's different on each page.

Make a sandbox with the current behavior

https://codesandbox.io/s/vue-instantsearch-double-query-request-zp7v6?file=/src/App.vue

What is the expected behavior?

To either keep the same URL, or have an option to toggle between the behaviour.

Does this happen only in specific situations?

No

What is the proposed solution?

As above.

What is the version you are using?

Vue 2.x, InstantSearch v3.8.1

Please let me know if it's different behaviour on IS v4.

I've just confirmed, and this is the case with every widget, as it's that way the same behaviour to click an item as it is to open it in a new tab, however you're right that for a hierarchical menu it may make sense to not toggle a refinement once one is selected, similar to radio inputs. Would that be the behaviour you want, or refine still working the same, only the urls being different (as if it was selected, not as if it was toggled)?

Yeah that's correct. I was having a think about this earlier and I think only Hierarchical Menu's at this stage. As Refinement lists are checkboxes, as you say, it makes sense to work as it currently does where it goes back to the parent when deselecting. But not when it's a radio btn/html link.

Do you know if this planned on being looked at @Haroenv?

We've not found a consensus on what the correct behaviour is, sorry. I'd recommend using a custom widget where you call createURL(item.isRefined ? '' : item.value) (pseudo code) to avoid the default behaviour @jonathan-bird. Sorry that I forgot to get back on this issue