No Index Auto-Generated Default Pages
Auto-generated default pages, such as cart, checkout, and account pages, can dilute your SEO efforts. To prevent search engines from indexing these pages, you can use the noindex
meta tag.
Shopify
In Shopify, you can add the noindex
tag by editing the theme’s theme.liquid
file. Follow these steps:
- Go to Online Store > Themes > Actions > Edit Code.
- Open the
theme.liquid
file. - Add the following code within the
section:
{% if template contains 'cart' or template contains 'checkout' or template contains 'account' %}
{% endif %}
To noindex specific Shopify pages such as /collections
(all collections), /collections/all
(all products), and /collections/new
(new products), you will need to modify the collection.liquid
template file and potentially add conditional logic to handle these specific URLs.
Here’s how you can do it:
1. Access Your Theme Code
- Login to Shopify Admin: Go to your Shopify admin dashboard.
- Navigate to Themes:
- From the admin dashboard, go to
Online Store
>Themes
.
- From the admin dashboard, go to
- Edit Code:
- Find the theme you are currently using.
- Click on
Actions
>Edit code
.
2. Edit the collection.liquid
Template
- Locate the
collection.liquid
file:- In the
Templates
folder, find and opencollection.liquid
.
- In the
- Add Conditional Noindex Meta Tags:
- Insert the following code within the
<head>
section of thecollection.liquid
file. This code will add anoindex
meta tag for the specified collection pages.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> {% if collection.handle == 'all' or collection.handle == 'new' %} <meta name="robots" content="noindex"> {% endif %} <title>{{ collection.title }}</title> ... </head> <body> ... </body> </html>
This code snippet uses Liquid conditions to check if the collection handle matches
'all'
or'new'
. If it does, it inserts anoindex
meta tag. - Insert the following code within the
3. Handle the /collections
Page Separately
The /collections
page lists all collections and may require a different approach. Typically, this is managed by the list-collections.liquid
file.
- Locate the
list-collections.liquid
file:- In the
Templates
folder, find and openlist-collections.liquid
.
- In the
- Add Noindex Meta Tag:
- Insert the
noindex
meta tag within the<head>
section:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="robots" content="noindex"> <title>All Collections</title> ... </head> <body> ... </body> </html>
- Insert the
4. Save and Publish
- After adding the
noindex
tags to the relevant template files, save your changes. - Publish the updated theme if necessary.
5. Verify the Changes
- Visit the pages you have noindexed and check the page source to ensure the
meta
tag is correctly included in the<head>
section. - Use tools like Google Search Console to confirm that these pages are not being indexed by search engines.
Summary of Code Changes
collection.liquid:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if collection.handle == 'all' or collection.handle == 'new' %}
<meta name="robots" content="noindex">
{% endif %}
<title>{{ collection.title }}</title>
...
</head>
<body>
...
</body>
</html>
list-collections.liquid:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex">
<title>All Collections</title>
...
</head>
<body>
...
</body>
</html>
By following these steps, you will ensure that the /collections
, /collections/all
, and /collections/new
pages are noindexed, preventing search engines from indexing these pages.
WooCommerce (WordPress)
In WooCommerce, you can use a plugin like Yoast SEO to add the noindex
tag. Follow these steps:
- Install and activate the Yoast SEO plugin.
- Go to SEO > Search Appearance > Content Types.
- Find the sections for Products, Product Categories, and Product Tags.
- Set the Show Products in search results? option to No for each section you want to noindex.
Alternatively, you can add custom code to your theme’s functions.php
file:
function noindex_woocommerce_pages() {
if (is_cart() || is_checkout() || is_account_page()) {
echo '';
}
}
add_action('wp_head', 'noindex_woocommerce_pages');