Hello everybody my name is Konstantinos, i hope this message finds you well.
The reason im making this topic is because im making an eshop and i reach to the point that i must change the url prefix(before the slug, tha is customizable in shopify) in greek, as you know excpet the slug we cannot change the url prefix for example www.shopify.gr/collections/slug the part collection belongs tou shopify structure and in order to change i ve hard that i can set up a worker in cloudflare and riderict the trafic tou my desired url that point the regular url with shopify content. Moreover i have a domain bought in hostinger that i transfered the dns setting in cloudflare in order to make the worker, i did make the worker with this code inside: export default {
async fetch(request) {
const url = new URL(request.url);
const routes = {
"/products": "/προϊόντα",
"/collections": "/συλλογές",
"/pages": "/σελίδες",
"/blogs": "/ιστολόγιο",
"/articles": "/αρθρά",
};
for (const \[el, en\] of Object.entries(routes)) {
if (
url.pathname === el ||
url.pathname.startsWith(el + "/")
) {
url.pathname = url.pathname.replace(el, en);
return fetch(new Request(url.toString(), request));
}
}
return fetch(request);
}
}; , althought i followed all the steps with gtp as a guider now i can continue because is things i don’t know, anybody can help me to set up the worker so it actually works.
Best regards,
Kostas
Your map is running in the opposite direction. A visitor requests /συλλογές/foo, so the Worker needs to rewrite that internally to /collections/foo before fetching Shopify. Your loop currently only matches /collections and changes it to a path Shopify doesn’t recognize.
That alone won’t fully localize the URLs. Shopify will still output English links and canonical tags, so a proper proxy also has to rewrite HTML and handle pagination, search, cart, apps, and redirects. I’d use Shopify’s native Greek locale path and keep the fixed prefixes unless you can test the proxy on a spare domain first.
Thanks for your reply clawmama, but i need a business alike solution my eshop is located in Greece,and i want everyting to be translated even the url prefixes.
For a production setup, there are two realistic choices. Keep Shopify’s fixed paths and use Markets for Greek content, or build a headless storefront where you control every route. A Cloudflare proxy can imitate translated prefixes, but then your team owns HTML link rewriting, canonicals, redirects, cart and checkout transitions, app routes, sitemaps, and regression testing after theme changes. Shopify doesn’t provide a native setting that translates /products or /collections.
Hi @venomkv13
At the moment, Shopify does not provide an option for URL prefix modification (like /products, /collections or /pages). This is due to their URL routing system.
It might be possible using a Cloudflare Worker, but it is not enough to only write the code. It should also be:
- Successfully deployed in your Cloudflare account.
- Set up on the appropriate route (for instance,
yourdomain.com/* or other routes you would like to catch).
- Designed to translate the Greek URL into the one which Shopify expects and send a forward request afterwards.
There is one more thing to notice - in your code it looks like /collections is mapped to /συλλογές. If the visitor requests the Greek version of the URL (/συλλογές/...), it should be translated into /collections by the Worker before sending a request to Shopify.
If something else is wrong and it is not working, then it would be very helpful to understand:
- Are you receiving a 404 or redirect loop, or is your Worker not being triggered?
- Have you attached the Worker to your domain route in Cloudflare?
This will greatly help us to understand where the problem lies.