Every store handles this badly at least once. A product sells out, someone unpublishes it, the URL starts returning a 404, and the rankings and links it had built up over two years disappear with it.
The right answer depends on one question: is it coming back?
If it is coming back
Keep the page live. Keep it indexable. Do not redirect it.
On the page:
- Say plainly that it is out of stock and give a date if you have one.
- Offer an email notification for when it returns. This is free demand capture and it converts well.
- Show close alternatives right there, not a generic "you may also like" carousel.
- Keep the
Productschema, and setavailabilitytoOutOfStock. Do not remove the markup. Google handles the out of stock state fine and removing the schema loses you the rich result when the product comes back.
Removing the product from your sitemap while it is out of stock is fine. Removing the page is not.
If it is gone for good
Now you redirect, and the destination matters more than most people think.
First choice: the closest equivalent product. A newer model, a different colour of the same thing, the direct replacement. This keeps the visitor close to what they wanted.
Second choice: the parent collection. Less ideal, because the visitor now has to choose again, but far better than a 404.
Last choice: the home page. Google treats bulk redirects to the home page as soft 404s and passes nothing. This is the most common mistake and it wastes the link value entirely.
Use a 301, not a 302. A 302 says the change is temporary and search engines keep the old URL in the index.
If it is seasonal
Treat it as coming back, because it is. Keep the URL, keep it indexed, and change the messaging rather than the page.
A page that has ranked for three winters is an asset. Deleting it every spring and rebuilding it every autumn means it starts from nothing each year.
If it never had traffic or links
Then it does not matter much. Check Search Console for impressions and check whether anything links to it. If both are zero, let it 404 and move on. A 404 is a valid response and a site with none is not necessarily healthy.
This is worth saying because the alternative is a redirect map with four thousand entries, which slows down every request and nobody maintains.
The rule underneath all of this
Before you unpublish anything, check two numbers: impressions in the last twelve months, and referring domains. Those two numbers tell you whether the URL is an asset or a row in a database.
Most stores have no process here, which is why we find whole categories of broken URLs in audits. Put one person in charge of what happens when a product is discontinued and most of this solves itself.
The bulk version
If you are dealing with hundreds at once:
- Export every product URL that returns a 404 or is unpublished.
- Pull twelve months of impressions and clicks for each from Search Console.
- Pull referring domains for each from Ahrefs or Semrush.
- Anything with traffic or links gets a hand-picked redirect target.
- Everything else can 404.
That turns an unmanageable list into a morning's work on the twenty per cent that matters.
This is part of e-commerce SEO and it overlaps with technical SEO when the redirect map gets large. If you are planning a replatform, the same thinking applies at a much bigger scale, and SEO for e-commerce stores covers how we approach it.