Removing Collection From Shopify URLs When Using Boost Pfs

Alexandre Hoffmann 10/05/2024 3 minutes
SEO

Why remove the collection folder on the product URLs?

Navigating the complexities of Shopify’s collection URL architecture has presented a significant challenge—its rigidity. Conversations with seasoned SEO specialists have confirmed my frustration; this aspect is universally challenging.

Further complicating this intricate technical SEO issue is automatically generating a new URL with each product added to a collection alongside the primary product URL. This mechanism is where the URL integrates both the collection and its name. It introduces an added layer of complexity to SEO optimisation efforts, necessitating a nuanced approach for effective management.

Duplicate content presents another compelling rationale for the desire to eliminate collection-aware URLs. Reflecting on the previously discussed examples, each of the four collection URLs, as well as the product URLs, culminates in identical end content—the product description. Should Google index all five URLs, one may encounter challenges with Google Page Index reporting, particularly concerning issues labelled as “Alternate page with proper canonical tag” and “Duplicate, Google chose different canonical.”

Shopify’s approach involves configuring the robots.txt file to suggest that only the product-only URL ought to be indexed, excluding the collection-aware URLs. However, it’s critical to understand that the directives in the robots.txt file serve as recommendations rather than absolute imperatives, leaving room for indexing collection-aware URLs.

By removing the collection folder and adding your products at root level, you will:

  • Reduce the URLs on your site, making it much easier for Google to crawl and index it.
  • Prevent the use of canonical tags to select the correct page.
  • Save yourself a lot of headaches, especially if you have a geo-targeted website.

 

How do we remove the nesting of the product within the collection folder?

The process is quite easy, but I recommend making a copy of your site and theme before proceeding, especially if you don’t have development experience.

1. Identifying the code to update

Within the Shopify admin panel, proceed to Online Store -> Themes -> select the ‘…’ -> Edit Code. Commence your search within the theme files for the term “within: collection”.

Locating this specific segment can prove somewhat challenging, given Shopify’s absence of a theme-wide search functionality, thus necessitating a file-by-file approach. In my case, with the Turbo version in question, the necessary modifications are to be made within the snippets/product-details.liquid and snippets/product-thumbnail.liquid files.

Given the unique nature of each theme, your search may direct you towards different files, possibly product-grid or product-loop. If the location of this code remains elusive, perusing each snippet file might be required. While Chrome extensions facilitate searching through Shopify theme files, I steer clear of Chrome — a decision rooted in reasons I’ll perhaps share another time.

Upon locating the “within: collection” code, we aim to change only this fragment.

The modification should resemble the following:

Before:

{{ product.url | within: collection }}

After:

{{ product.url }}

It may be necessary to conduct multiple searches to ensure all instances of | within: collection are eradicated, as it’s common for themes to replicate the same code snippet across various locations.

Ensure to save any changes made to the files and evaluate the outcome.

2. Conducting a page test

Following any adjustments to theme files, it is imperative to verify promptly that nothing has been compromised.

Be mindful that Shopify significantly caches pages, potentially delaying the visibility of your adjustments on the live website by several minutes.

To assess your modifications, choose a collection and randomly select a product. The URL displayed should now omit both the collection and collection name.

3. Implementing redirects

Should your website already be live with previously indexed collection-based product URLs, remember to establish URL redirects. Neglecting this crucial step could inadvertently direct potential customers to error pages, impacting user experience.

 

What happens if you are using Boost PFS?

If you use the boost PFS app, you will notice that the URLs you have changed will revert back, which is very annoying…

To fix this, follow the instructions below!

 


And there you have it: an SEO-friendly and headache-free site structure.