When a product is permanently discontinued and has no organic traffic or external links, it’s best to use a 410 status code to inform search engines that the content is gone for good. Here’s how to do it on Shopify and WooCommerce:
Shopify
Using a 410 status code for discontinued products on Shopify is a way to inform search engines that the product page has been permanently removed. This helps ensure that the discontinued product pages are properly deindexed, which can improve the overall SEO health of your site. Here’s how you can implement a 410 status code for discontinued products on Shopify:
Steps to Implement 410 Status Code for Discontinued Products
- Identify Discontinued Products:
- Make a list of all the products that are no longer available and won’t be restocked.
- Create a Template for 410 Status Code:
- Since Shopify doesn’t directly support returning a 410 status code out of the box, you’ll need to use a workaround by editing your theme’s code.
- Edit Your Theme’s Code:
- Go to your Shopify Admin dashboard.
- Navigate to Online Store > Themes.
- Click on Actions next to your current theme and select Edit Code.
- Create a New Template for Discontinued Products:
- In the Templates directory, click Add a new template.
- Choose liquid as the file type and name it something like
discontinued-product
. - Add the following code to this new template:
{% layout none %} {% include 'header' %} <meta name="robots" content="noindex"> <h1>Product Not Found</h1> <p>This product is no longer available.</p> {% include 'footer' %}
- Create a Snippet for 410 Status Code:
- In the Snippets directory, click Add a new snippet and name it
discontinued-410
. - Add the following code to this snippet:
{% layout none %} {% include 'header' %} {% capture 410status %} HTTP/1.1 410 Gone Content-Type: text/html {% endcapture %} {{ 410status | strip_newlines }} <meta name="robots" content="noindex"> <h1>Product Not Found</h1> <p>This product is no longer available.</p> {% include 'footer' %}
- In the Snippets directory, click Add a new snippet and name it
- Assign the 410 Template to Discontinued Products:
- For each discontinued product, edit the product in Shopify Admin.
- Scroll down to the Theme templates section.
- Select the
discontinued-product
template from the dropdown.
- Set Up URL Redirects (Optional but Recommended):
- Redirect the discontinued product URLs to a relevant category page or a custom 404 page to maintain a good user experience.
- Navigate to Online Store > Navigation > URL Redirects.
- Create redirects for each discontinued product URL.
Benefits of Using a 410 Status Code
- SEO Clarity: Tells search engines that the content is gone permanently, which helps them update their index accordingly.
- User Experience: Prevents users from landing on a non-existent page, reducing bounce rates.
- Site Health: Keeps your site’s index clean and helps maintain its overall SEO performance.
By following these steps, you can effectively manage discontinued products on your Shopify store and maintain good SEO practices.
WooCommerce
- Install and activate the Redirection plugin from the WordPress plugin repository.
- Go to Tools > Redirection.
- Click on Add New to create a new redirection.
- In the Source URL field, enter the URL of the discontinued product.
- In the Target URL field, enter a non-existent URL (e.g., /410-gone).
- In the Group dropdown, select Redirections.
- Click Add Redirect.
- Now, you need to handle the 410 status code. Add the following code to your theme’s functions.php file:
add_action('template_redirect', 'handle_410_status'); function handle_410_status() { if (is_404() && strpos($_SERVER['REQUEST_URI'], '/410-gone') !== false) { status_header(410); nocache_headers(); include(get_query_template('410')); exit; } }
- Create a new file named 410.php in your theme’s root directory and add your custom 410 error message.