add-to-cart page

How to Exclude the Add-to-Cart Page from Indexing in WordPress

When running an online store with WordPress, you want search engines to index only the most relevant pages, such as product pages and categories. Indexing unnecessary pages—like the add-to-cart page—can clutter search results and negatively impact SEO.

In this article, we’ll show you how to exclude the add-to-cart page from indexing in WordPress.

The Add to Cart page indexing arises because it looks like a page. The search engine Indexes the page as soon as it finds permission from robots.txt. Most website owners keep the default robots.txt format, which lets search engines crawl the page. However, there are ways that any page can be set to noindex for search engines. Ensure you follow the right approach and test it in the Webmaster tool for indexing issues

1. Use the noindex Meta Tag Manually

You can manually set the page to noindex in the header section. Once you are done, the meta tag will inform search engines not to index the page.

  • Go to Appearance > Theme File Editor in your WordPress dashboard.
  • Open the header.php file or the relevant template for the add-to-cart page.

Add this code before the </head> section of the template:

<?php if ( is_page(‘add-to-cart’) ) : ?>

<meta name=”robots” content=”noindex, nofollow”>

<?php endif; ?>

  • This code checks if the current page is named “add-to-cart” and adds the noindex tag.
  • Replace ‘add-to-cart’ with your exact page slug if it’s different.

2. Use the Yoast SEO Plugin

Yoast SEO is one of the easiest ways to manage meta tags without touching code. Here’s how to exclude the add-to-cart page using Yoast SEO:

If you have downloaded and are using the plugin, follow these steps.

  1. Go to SEO > Search Appearance.
  2. Click on the Content Types tab or Pages section.
  3. Find the add-to-cart page in the list.
  4. Set the Show this Page in Search Results option to No.

Yoast will now automatically add a noindex tag to that page.

3. Use the Robots.txt File

The robots.txt file tells search engines which parts of your website to avoid. You can block the add-to-cart page from being indexed through this file.

  • Go to SEO > Tools in the Yoast SEO plugin (or manually access your file manager).
  • Click on File Editor or create a new robots.txt file if it doesn’t exist.

Add this line to the robots.txt file:

Disallow: /add-to-cart/

  • This tells search engines not to crawl the add-to-cart page.
  • Replace /add-to-cart/ with the correct path if your URL structure differs.

4. Redirect the Add-to-Cart Page Temporarily

To avoid indexing issues, redirect the add-to-cart page. Use a redirection plugin like Redirection to send users to a more relevant page.

Install and Activate Redirection

  • Go to Plugins > Add New.
  • Search for Redirection, install, and activate it.

Set Up the Redirect

  1. Go to Tools > Redirection.
  2. Click Add New Redirect.
  3. In the Source URL, enter /add-to-cart/.
  4. In the Target URL, enter the URL where you want to redirect users.
  5. Save the changes.

This will ensure users never land on the add-to-cart page directly.

5. Monitor with Google Search Console

After making changes, use Google Search Console to ensure the add-to-cart page is not indexed. Here’s how:

  1. Go to Google Search Console and open your property.
  2. Use the URL Inspection Tool to check if the add-to-cart page is excluded.
  3. If the page is still indexed, request removal through the Remove URLs tool.

This helps you keep your search results clean and focused.

Conclusion

Excluding the add-to-cart page from indexing ensures a cleaner search engine presence and better SEO performance. You can set this up through meta tags, Yoast SEO, robots.txt, or redirections. Each method is simple and practical—choose the one that best suits your needs.