Removing WooCommerce noindex Tags on Account Login Page

A shop window full of second hand books

If you have a website using WooCommerce and have registered it with the new version of Google Search Console, it's likely that you will get an email notification about 'index coverage' issues for the /my-account/ page (Or your custom url for the same page).

Whilst it's logical that you wouldn't want account pages indexed by a search engine, when a user isn't logged in, the account page shows the account login form.

Adding a noindex robots tag to the login page prevents it from being shown in search results, often prominently when someone searches for your store by name.


Google search results page when searching by store name showing a prominent link to the account page login

WooCommerce has some conditional tags to detect different pages. Whilst it looks like is_account_page() should work, this only seems to return true after login.

There is an action which adds the tag which can be removed. I opted to check if a user is logged in or not, and if not, remove the robots tag. Search engines don't create accounts anyway and can't index pages which are restricted to logged in users.

The following snippet can go in your theme's functions.php file or a custom plugin (Change YOURPREFIX to something unique):

Once added, clear any caching plugins you have on the site and then go back to Search Console to validate the fix.