Robots.txt best practices: block cart and sign-up links
Google's guide to maintaining a site's SEO says to use robots.txt rules to stop crawling and sitemaps to encourage it, and to block URLs that change state, such as posting comments, creating accounts or adding items to a cart.
What it means for your Maryland business
Robots.txt best practices, according to Google, come down to three rules: use it to keep crawlers away from addresses that do something rather than show something, such as add-to-cart, account sign-up and comment-posting links; never use it to hide a page from results, which takes a noindex tag or a login; and never block the images, CSS and scripts Google needs to see your pages properly. Robots.txt is a file of rules telling crawlers which addresses to stay away from. For Maryland businesses, the state-changing rule matters most for sites with an online store, customer accounts, booking forms or comment sections: retailers, restaurants with online ordering, salons with appointment booking, nonprofits with member portals and publishers.
Each spring, a Frederick florist's server slows down as crawlers chase the new web address its online shop creates every time someone clicks add to cart for a bouquet. The developer adds robots.txt rules blocking the cart and checkout addresses, leaves the product and category pages open, and keeps the sitemap listing every bouquet page so Google prioritizes the pages customers actually shop before Mother's Day.
Misusing robots.txt takes several forms Google calls out. Using it to keep a private or outdated page out of Google is the first, and Google says that is not what robots.txt is for. Blocking the CSS or image folders can keep Google from crawling pages properly, and an old rule can leave important pages blocked. After editing robots.txt, use the URL Inspection tool to render a live page and confirm Google sees it as you expect. For links visitors post in comments, Google suggests rel=nofollow so their quality doesn't reflect on you.
In Google's words
“Block access to URLs that change state, such as posting comments, creating accounts, adding items to a cart, and so on. Use robots.txt to block these URLs.”
What Google says
Google's guide to maintaining a site's SEO says to use robots.txt rules to stop crawling and sitemaps to encourage it, and to block URLs that change state, such as posting comments, creating accounts or adding items to a cart. It warns that robots.txt is not a way to prevent indexing, which needs a noindex tag or a login requirement, and that resources Google should crawl, like images and CSS, must not be blocked. It also suggests blocking duplicate content and unimportant, frequently requested resources that might overload a server.
Where to go next
The entries on either side of this one in Getting found by Google.
