I have a /products
page.
In that page, users may use filters to select the products they want to see.
Those filters will work using query strings like: /products?brands=X,Y&size=1,2
and so on.
I don't want good to index any of the filtered pages. I just need the root /products
crawled and index.
Through my website, Google will not find those query string links, because my filter buttons are just regular HTML buttons that will call history.push()
behind the scenes. So, there are no "visible" links with query strings on my page that Googlebot might find.
On my Sitemap.xml
, only the root /products
will be included of course.
But it's not impossible that one of my users could post my link somewhere on the web like this:
/products?some_query_string_with_filters
And Googlebot would eventually find out about it, even though I'm not showing it.
So I need a way to block Google from indexing that. What would be the best way of doing that?
OPTION #1
Try to add some Disallow
on robots.txt
. Which would not allow Google to crawl my page when there is a query string present?
Something like Disallow: /products?
OPTION #2
Let Google crawl it, but render a noindex
meta tag when the page is rendered with active filters (which implies the query string would also be active).
OPTION #3
Try to detect (from user-agent
) that a robot is fetching the page /products?something
, and 301
redirect it to the root page /products
without the query string.
OPTION #4
Let google crawl it and always keep a rel canonical
pointing to the URL /products
without the query string and trust that Google will most likely not index any links with query strings.
Is there a best practice / standard way of doing this?