Shopify

Beyond /products: Customizing Shopify URL Prefixes for Global Stores

Hey everyone! As a Shopify migration expert at Shopping Cart Mover, I often see store owners grappling with the nuances of internationalization. One of the most common questions, especially for those in non-English speaking markets, revolves around customizing Shopify's core URL prefixes. You know, those standard bits like /products, /collections, or /pages that Shopify uses by default.

Recently, a fantastic discussion popped up in the Shopify community, initiated by Kostas (venomkv13), who was looking to translate these prefixes into Greek for his e-shop. He wanted /collections to become /συλλογές, for instance, and had started down the path of using a Cloudflare Worker. This is a brilliant example of a common challenge, and the community really rallied to provide some deep insights.

Cloudflare Worker code for Shopify URL prefix translation
Cloudflare Worker code for Shopify URL prefix translation

The Shopify URL Prefix Challenge: Why It's Tricky

First off, let's address the elephant in the room: Shopify doesn't natively offer an option to change these core URL prefixes. As Hardeep and clawmama pointed out in the thread, this is due to Shopify's fundamental URL routing system. These prefixes are hardcoded into the platform's core to ensure consistent and reliable routing for all stores. So, if you're aiming for a fully localized URL structure where even /products is translated, you're venturing into custom development territory.

Kostas's idea of using a Cloudflare Worker is indeed the most common workaround for this. A Worker essentially acts as a proxy, intercepting requests to your domain before they reach Shopify, and then modifying them. But as the community discussion revealed, it's not as simple as just dropping in a bit of code.

The Cloudflare Worker Approach: Getting the Direction Right

Kostas shared his initial Worker code, which looked something like this (mapping English to Greek):

const routes = {
  "/products": "/προϊόντα",
  "/collections": "/συλλογές",
  // ... etc.
};

The core bug, as highlighted by VikashJ and clawmama, was that this mapping runs backwards for the inbound request. A visitor requests /συλλογές/..., but Shopify only understands /collections/.... Therefore, the Worker needs to translate the incoming Greek URL *back* to the English equivalent before forwarding it to Shopify. Shopify has no idea what /συλλογές means!

The Corrected Worker Logic

Here's the corrected direction for your Cloudflare Worker, ensuring that incoming localized URLs are translated into Shopify-understandable paths:

export default {
  async fetch(request) {
    const url = new URL(request.url);
    const routes = {
      "/προϊόντα": "/products",
      "/συλλογές": "/collections",
      "/σελίδες": "/pages",
      "/ιστολόγιο": "/blogs",
      "/αρθρά": "/articles"
    };

    for (const [gr, en] of Object.entries(routes)) {
      if (url.pathname === gr || url.pathname.startsWith(gr + "/")) {
        url.pathname = url.pathname.replace(gr, en);
        return fetch(new Request(url.toString(), request));
      }
    }
    return fetch(request);
  }
};

Beyond the URL: The HTML Rewriting Necessity

As VikashJ and clawmama also flagged, fixing the URL path alone won't fully localize anything. The HTML Shopify returns will still contain /products and /collections in every internal link, navigation menu, canonical tag, and pagination link. Visitors will land on your Greek URL, then click any link on the page and get bounced right back to English paths.

To actually fix that, your Worker needs a second stage: intercept the HTML response and rewrite matching href attributes before returning it to the browser. Cloudflare Workers support this natively using HTMLRewriter. This is a significant added layer of complexity, as you'll need to parse the HTML and replace all instances of English prefixes with their localized counterparts.

Essential Cloudflare Infrastructure Checklist

Even with the correct code, the Worker won't function if your Cloudflare setup isn't right. Steve_TopNewYork and Hardeep provided a crucial checklist:

  • Worker Route: Ensure your Worker route is set to catch all relevant traffic, typically yourdomain.com/*.
  • DNS Record: Your DNS record in Cloudflare must be set to Proxied (orange cloud), not DNS-only. This ensures Cloudflare intercepts the traffic.
  • Verify Worker Execution: Add a temporary console.log or return a test header within your Worker to confirm that requests are actually hitting it.
  • Custom Domain: Confirm the Worker is attached to your custom domain, not just deployed without a route.

Native Shopify Solutions & Long-Term Considerations

While a Cloudflare Worker can achieve URL prefix translation, it's crucial to weigh the long-term maintenance costs and consider native Shopify solutions.

Shopify Markets for Multilingual Content

Hardeep and clawmama strongly suggested Shopify Markets for a native Greek locale. Shopify Markets is designed to handle multi-language and multi-currency stores, providing a robust, officially supported way to offer localized content. While it won't translate the core /products prefix, it will allow for localized content, currency, and potentially subdomains or subfolders (e.g., yourdomain.com/el/products/) which is often sufficient for SEO and user experience.

Headless Commerce for Ultimate Control

For merchants who demand absolute control over every aspect of their storefront, including all URL structures, a headless Shopify setup is the most comprehensive solution. This involves using Shopify as a backend (for products, orders, etc.) and building a custom frontend using frameworks like React or Next.js. This gives you complete freedom over routing, design, and content delivery, but it comes with significantly higher development and maintenance costs.

Weighing Your Options

The custom proxy route works, but it becomes your team's permanent responsibility. Every time your theme changes, new apps are installed, or Shopify updates its core functionality, you'll need to regression test and potentially update your Worker's HTML rewriting logic. This can be a significant hidden cost. For merchants looking to establish a robust international presence, starting your Shopify store today provides a powerful foundation, and leveraging its native tools like Shopify Markets often offers a more sustainable path to localization.

Conclusion

Customizing Shopify's core URL prefixes for internationalization is a common desire, and Cloudflare Workers offer a viable, albeit complex, technical workaround. However, it's vital to understand the full scope of the challenge: not just URL rewriting, but also HTML content rewriting and ongoing maintenance. For many businesses, exploring Shopify Markets or even a headless approach might offer a more robust and scalable long-term solution.

At Shopping Cart Mover, we specialize in navigating these complex e-commerce challenges. Whether you're considering a migration, optimizing your international strategy, or need expert development assistance, our team is here to help you make informed decisions that drive your business forward.

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases