How to Change 404 Error Code to 410 Gone for Deleted Pages in Shopify?

Hi Shopify Community,

I’m a beginner to Shopify, and I’m trying to improve my site’s SEO by ensuring that deleted pages return a 410 Gone status code instead of the default 404 Not Found. A 410 status code would better inform search engines that these pages are intentionally and permanently removed.

I understand that Shopify automatically sets deleted pages to return a 404 error, but is there a way to customize this behavior through code?

Question: Can I modify the 404.liquid template and change the code to a “410 Gone” message?

Any advice or code examples would be greatly appreciated!

Thank you in advance for your help!

Hi @lovflowers ,

Shopify automatically returns a 404 Not Found status for deleted pages, and unfortunately, you can’t change this to a 410 Gone status through code because Shopify doesn’t allow server-level customizations.

However, you can customize the 404 page to display a “410 Gone” message to inform visitors and search engines that the page has been permanently removed. Here’s how to do it:

  1. Go to Online Store > Themes > Actions > Edit Code.
  2. Open the 404.liquid file (or create one if it doesn’t exist).
  3. Add this message:
# 410 Gone

This page has been permanently removed.

  1. Save the changes.

While this won’t change the HTTP status code, it helps communicate to users and search engines that the page is gone. For SEO, you can also set up URL redirects for deleted pages to prevent search engines from indexing them.

Let me know if you need more help!

If my reply is helpful, kindly click like and mark it as an accepted solution.

If you are happy with my help, you can help me buy a COFFEE

Thanks!

Hi, Thank you very much. I’m trying to add the 410 gone message in the code, but I’m unsure which liquid file I should pick.

There seems to be a few different ones called 404. Do you know which one I should pick? I just searched “404”.

Thank you very much!

It seems as I don’t have a file in the code that’s called 404.liquid

How do I add one? Should I add one under layout, template, sections, snippets, config, assets, or locales?

@lovflowers ,

In the screenshot, the file you need to edit for adding the 410 Gone message is most likely the 404-template.liquid file located under the Sections folder. This file is where the actual HTML structure and content for the 404 page are typically defined.

Here’s what you can do:

  1. Open 404-template.liquid under the Sections folder.

  2. Add the HTML for the 410 Gone message, for example:

# 410 Gone

The page you are looking for has been permanently removed.

  1. Save your changes and preview the 404 page to confirm.

If editing this file doesn’t work as expected, you can try editing the 404.json file under Templates, but this is more about the page’s structure than its content. Let me know if you need further guidance!