Hreflang Cleaner

Documentation

How to install, configure and verify Hreflang Cleaner. Written to be read by an SEO specialist and by someone who has never heard the word “hreflang”.

In short

  • An hreflang tag tells search engines: “this page also exists in this language, at this address”.
  • Shopify Markets generates them all by itself, crossing every market with every language — including combinations that do not exist commercially.
  • Hreflang Cleaner replaces them with the exact list you tick. Nothing more, nothing less.

What it is for

Your store speaks several languages and sells in several countries. For a search engine to send a French-speaking Belgian to your French version and an American to your English one, every page has to declare where its equivalents live. That is what hreflang tags do: invisible to your visitors, they sit in the <head> of the page's code.

The problem

Shopify Markets fills those tags in automatically, crossing every market with every published language. A “United Arab Emirates” market served in English therefore ends up advertising an fr-ae version you never wanted. Search engines crawl those addresses, index them, and your useful signal drowns in the noise. On a catalogue of a few thousand products, that means tens of thousands of parasitic URLs.

The fix

  • You tick, in a market × language grid, only the pairs that make sense for your business.
  • The app computes the matching address for every page and stores it in a Shopify metafield.
  • A block added to your theme reads those metafields and writes the tags into the <head>.
  • A daily sync keeps everything current, whether you have 20 or 200,000 pages.
The app does not modify any of your theme files: it adds a block, which Shopify removes automatically if you uninstall.

Getting started

Setup happens once, in three steps, under the Setup tab. The dashboard only opens at the end — that is deliberate: half-configured tags do more damage than no tags at all.

  1. Turn off Shopify's automatic hreflang tags. In your admin: Online Store → Preferences → Social sharing and SEO → uncheck Automatic hreflang tags. Without this step, Shopify's tags and the app's coexist: search engines see two contradictory sets and trust neither. Shopify exposes no API to read that preference, which is why the app asks you to confirm.
  2. Tick your market × language pairs and save. A live preview shows the exact tags that will be published, before anything goes out.
  3. Enable the block in your theme. The button in step 3 opens the theme editor at the right place: switch “Hreflang Cleaner” to Enabled, then save.

All that is left is Finalize and sync. The first full computation runs in the background: seconds on a small store, a few hours on 200,000 resources. The dashboard shows progress, and you can close the tab in the meantime.

Whatever is still missing is listed under the Finalize button, so you never have to guess what is blocking. And if your store has no market and no web presence in Shopify Markets yet, setup cannot complete at all — the app then offers you the dashboard anyway rather than locking you out.

Choosing your pairs

This is the one decision that takes a little thought. Every ticked box publishes a tag. The right question is not “is this technically possible” but “do I want a search engine to send this audience to this version of my store”.

Three rules are enough

  • One pair per language actually served on a market. If your Germany market only sells in German, tick German only — even if your store offers five languages.
  • Do not invent an audience. A Spanish version of a Japanese market nobody visits does not need to be advertised.
  • Exactly one pair as x-default. That is the version served to visitors whose language and country match none of what you ticked. Usually your primary market and language.

The codes

The app pre-fills each box's code (fr, fr-be, de-ch…) from your Shopify markets. You can correct it by hand. Two things to watch, both flagged by the preview: a code must be either a bare language (fr) or a language plus a real country (fr-ca) — en-EU and en-UK do not exist and are ignored; and no two boxes may carry the same code, or only one of the two addresses is kept, arbitrarily.

The “Synthetic URL” label on a box means that market has no dedicated web presence in Shopify: the app inferred the address from your primary domain. It is often right, but check the URL in the preview before saving.

Checking it works

Test mode, at the top of the Setup tab, publishes your tags as HTML comments: visible in the page source, invisible to search engines. That is how you look at the result without touching your rankings.

  1. Turn test mode on, then wait a minute or two for Shopify's cache to refresh.
  2. Open a product page on your store, view the page source (Ctrl+U, or Cmd+U on a Mac) and search for “hreflang”.
  3. Compare with the preview in step 2: it should be identical.
  4. Turn test mode off to publish your tags for real.

After that the dashboard is enough: it shows the published tags, how many pairs are active, whether the block is live on your theme, whether native hreflang is off, and when the last sync ran. A daily automated check reads a few pages of your store and raises an alert if it finds duplicate tags or a disabled block.

Day to day

Once configured, the app does not need you. These are the only cases where it asks for something.

  • You add or edit a product, page or article: nothing to do, the daily sync picks it up within 24 hours. The Run sync again button on the dashboard forces a pass immediately if you are in a hurry.
  • You add a market or a language in Shopify: the app ticks nothing on your behalf, precisely because not all combinations are equal. Go back to step 2, tick the relevant new pairs, save.
  • You publish a new theme: Shopify does not carry app blocks over from one theme to the next. The app detects it right away and asks you to re-enable the block.
  • You delete a product or a collection: the matching metafields are cleaned up immediately.
The 24-hour delay is a deliberate choice: one mechanism, identical for a 20-product store and for a 200,000-item catalogue. The only events handled in real time are the ones that cannot wait — deletions, theme publication and language changes.

If something looks wrong

  • “Duplicate hreflang tags”. Shopify's automatic hreflang tags are active again. Redo step 1 — by far the most common case.
  • “Theme block disabled”. The block was removed in the theme editor, or you just published a new theme. Re-enable it from step 3.
  • No tags in the page source. Check in this order: block enabled, at least one pair saved, test mode off — then wait two minutes.
  • “No markets found” or “no web presence”. Setup cannot complete until Shopify Markets is configured (Settings → Markets). The app lets you reach the dashboard meanwhile, but it will publish nothing before then.
  • Your domain is still a .myshopify.com one. The tags would point at that technical domain. Connect your real domain before publishing.
  • The preview addresses do not match your store. The markets involved probably have no dedicated web presence (the “Synthetic URL” label). Configure one in Settings → Markets, then reload step 2.

If your case is not in this list, the FAQ covers the finer questions, and the support channel listed on the app's App Store page answers within 24 working hours.

What the app touches

  • It writes a hreflang.urls metafield on your products, collections, pages, articles and blogs, plus a shop-level hreflang.config metafield for pages with no resource of their own (home, cart, search, policies).
  • It reads your markets, languages, themes and translations.
  • It does not touch your theme files, your products, your prices or your orders.
  • It sees no customer data — no orders, no contacts. Neither the permissions requested at install nor the app's code allow it.
On uninstall, Shopify removes the block from your theme: the tags stop being rendered immediately. The metafields already written stay on your resources, with no effect since nothing reads them any more; you can delete them by hand if you want a full cleanup. Shopify's “Automatic hreflang tags” preference stays wherever you left it.