In short
Every address cited in an hreflang annotation must be complete: protocol, host name and path, for example https://example.com/en/pricing/. The forms /en/pricing/ and //example.com/en/pricing/ are not accepted. Once the task is done, every hreflang URL on the site, in tags, HTTP headers and sitemaps, is absolute, uses https, sits on the production domain and is identical to the canonical of the page it targets.
Why it matters
Google's documentation on localized versions is explicit: variant URLs must be fully qualified and include the protocol (http or https). It cites the two counterexamples to avoid itself: //example.com/foo and /foo.
In an ordinary HTML document, a browser resolves a relative URL without difficulty. For hreflang, Google does not take that gamble: an annotation whose URL is not complete cannot be used.
The absolute URL must also be the right one. The versions in a group only recognize each other if the addresses match exactly: an annotation pointing to http://example.com/en/pricing/ does not confirm a page whose URL is https://example.com/en/pricing/. Three causes produce most wrong URLs:
- the application sits behind a proxy, a CDN (Content Delivery Network) or a load balancer that talks to it over HTTP, and it generates
http://links; - the base URL is set to the staging domain, or to an address without
wwwwhen the site is served with it; - the template writes relative paths, because that is the convention for navigation links.
What it improves
- Usable annotations Full URLs are the condition for Google to link the versions.
- Reciprocity URLs generated the same way everywhere match each other exactly; see check reciprocity (opens in a new tab).
- Consistency with the canonical The same function produces both, with no protocol or host mismatch.
- Robustness Pages copied by an aggregator or displayed from a cache keep annotations that point to your domain.
- Rankings, AI answers No direct effect.
How to check
Show a page's annotations and spot those that do not start with https://:
curl -s https://example.com/fr/tarifs/ | grep -o -i '<link[^>]*hreflang[^>]*>' | grep -v 'href="https://'
Correct result: no lines. To check the host as well, replace the last filter with grep -v 'href="https://example.com/'. If your versions are on country domains (example.de), it is normal for them to show up: check that they are indeed the production domains.
In a sitemap:
curl -s https://example.com/sitemap.xml | grep -o 'xhtml:link[^>]*' | grep -v 'href="https://'
For a PDF:
curl -sI https://example.com/fr/guide.pdf | grep -i '^link:'
Each URL between < and > must be complete.
Other ways:
- Screaming Frog: with "Store Hreflang" and "Crawl Hreflang" ticked, export the Hreflang tab and filter the addresses that do not start with
https://. The "Not Using Canonical" and "Non Canonical Return Links" filters also flag annotations that do not use the canonical URL. - Merkle's hreflang tester: shows the URLs as they are written in the page.
How to implement
Before you start
One URL form for the whole site: https, the chosen host (with or without www), a trailing slash policy, no tracking parameters. It is set in standardize HTTP/HTTPS and www/non-www (opens in a new tab) and checked in check canonicals and absolute URLs (opens in a new tab).
Expected form:
<link rel="alternate" hreflang="fr" href="https://example.com/fr/tarifs/">
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing/">
To avoid:
<link rel="alternate" hreflang="en" href="/en/pricing/">
<link rel="alternate" hreflang="en" href="//example.com/en/pricing/">
<link rel="alternate" hreflang="en" href="http://example.com/en/pricing/">
<link rel="alternate" hreflang="en" href="https://staging.example.com/en/pricing/">
A <base href> tag does not solve anything: write the full URL in every annotation. Generate the canonical and hreflang with the same function, so that they cannot diverge.
Apache
Versions Apache 2.4.
If Apache is the reverse proxy in front of the application, pass on the original protocol and host so that the application generates https URLs:
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost On
For a Link header on a PDF, hard-code the full URL:
<Files "guide.pdf">
Header set Link "<https://example.com/fr/guide.pdf>; rel=\"alternate\"; hreflang=\"fr\", <https://example.com/en/guide.pdf>; rel=\"alternate\"; hreflang=\"en\""
</Files>
Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.18 and later.
In front of an application (Node.js, PHP-FPM), pass on the host and protocol:
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
}
For PHP-FPM, check that fastcgi_param HTTPS $https if_not_empty; is present (included in fastcgi_params on most distributions). Reload with sudo nginx -t && sudo systemctl reload nginx.
Cloudflare
Versions Cloudflare dashboard, all plans, November 2026.
In the "Flexible" SSL/TLS mode, Cloudflare reaches your server over HTTP: the application believes it is served over http:// and may write that in its annotations. Install a certificate on the origin, then, in SSL/TLS > Overview, choose the custom "Full (strict)" option, or let the automatic mode (Automatic SSL/TLS) pick the most secure mode the origin supports. Then purge the cache to replace the pages already stored.
AWS
Versions Application Load Balancer, CloudFront and S3, AWS console, November 2026.
Behind an Application Load Balancer, the application receives HTTP with the X-Forwarded-Proto header: configure it to trust the proxy (see Laravel, Symfony, WordPress, Drupal). Behind CloudFront, forward the Host or CloudFront-Forwarded-Proto header to the origin in the origin request policy, or hard-code the base URL in the application. On a static S3 site, the base URL is the generator's, to be set at build time.
WordPress
Versions WordPress 6.4 to 7.1; WPML 4.5 and later for per-language domains.
Multilingual plugins build URLs from the site settings:
Settings > General: "WordPress Address (URL)" and "Site Address (URL)" inhttps://on the final domain.- Behind a proxy or a CDN that terminates TLS, add this to
wp-config.php, before the linerequire_once ABSPATH . 'wp-settings.php';:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
- With WPML and a different domain per language, each domain entered in
WPML > Languagesmust be the full production address.
After a migration from staging, replace the old domain in the database with a search-and-replace tool that handles serialized data, then clear the caches.
Shopify
Versions Shopify admin, all plans, November 2026.
Shopify Markets' automatic tags are absolute and follow the domains configured for each market. Check that each market's primary domain is the one you want indexed.
Drupal
Versions Drupal 10 and 11.
Content Translation generates absolute URLs from the request. Behind a proxy, declare it in settings.php so that Drupal keeps the original protocol and host:
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['10.0.0.10'];
Replace the address with your proxy's, then run drush cr.
Laravel
Versions Laravel 10 to 13. Only where proxy trust is configured changes from Laravel 11 onwards.
route() and url() return absolute URLs, built on the request's host and protocol. Do not use route('...', absolute: false) for annotations. Two settings prevent wrong URLs:
APP_URL=https://example.comin.env, used outside HTTP requests (queues, sitemap generation from the command line);- trusting the proxy, so that the application keeps the original protocol and host.
Laravel 11 to 13
In bootstrap/app.php:
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})
Restrict at to your proxies' addresses when you know them.
Laravel 10
The app/Http/Middleware/TrustProxies.php middleware is already registered in app/Http/Kernel.php. Set its $proxies property:
protected $proxies = '*';
Replace '*' with an array of your proxies' addresses when you know them.
Symfony
Versions Symfony 6.4, 7.4 and 8.x.
Use url() in Twig, never path(), which produces a relative path. Behind a proxy, declare it in config/packages/framework.yaml:
framework:
trusted_proxies: '127.0.0.1,REMOTE_ADDR'
trusted_headers: ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port']
For URLs generated from the command line (sitemaps), set default_uri: 'https://example.com' under framework.router.
Next.js
Versions Next.js 15 and 16 (App Router).
Declare metadataBase in app/layout.tsx; Next.js then completes the relative paths in alternates.languages:
export const metadata = {
metadataBase: new URL('https://example.com'),
};
Next.js refuses to build a relative URL field without metadataBase. Take the value from an environment variable if staging has its own domain, checking that it is indeed the production domain in the production build.
Nuxt
Versions Nuxt 3 and 4, with the @nuxtjs/i18n module 9 and 10.
With @nuxtjs/i18n, the baseUrl option is required for alternate links to be complete:
export default defineNuxtConfig({
i18n: {
baseUrl: 'https://example.com',
},
});
Astro
Versions Astro 5 and 6.
Set site: 'https://example.com' in astro.config.mjs, then build each URL with new URL(path, Astro.site).href. Without site, Astro.site is undefined and URLs cannot be completed.
Common mistakes
- Copying the logic of navigation links, relative out of habit, into the annotation template.
http://URLs behind Cloudflare or a load balancer: the application does not know the original request was over HTTPS.- Staging domain in production:
APP_URL,metadataBaseorsiteurlleft onstaging.example.com. - A host different from the canonical: annotations without
www, canonical with it, or the reverse. - Protocol-relative URLs (
//example.com/…), sometimes produced by old themes. - Fixing the tags but not the sitemap or the HTTP headers, when several methods coexist.
Frequently asked questions
Can you use relative URLs in hreflang tags?
No. Google's documentation requires fully qualified URLs, with the protocol: https://example.com/foo is accepted, but not /foo or //example.com/foo. A relative URL works for a navigation link, not for an hreflang annotation. Generate the URLs with a function that produces the absolute address, the same one used for the canonical tag, and check the result in the source code served.
Can hreflang URLs point to another domain?
Yes. Google states that a page's variants do not need to be on the same domain: example.fr can announce its German version on example.de. Each URL simply has to be complete and use https, and the target page must respond with its own annotations pointing back to the first. Country domains, subdomains and subdirectories can therefore be mixed in the same group.
Why are my hreflang annotations in http when the site is in https?
It is almost always a proxy: Cloudflare in Flexible mode, a load balancer or an Nginx server reaches the application over HTTP, and the application then generates http addresses. Switch Cloudflare to Full (strict), pass on the X-Forwarded-Proto header and configure the application to trust the proxy, or set the base URL to https in its configuration. Then purge the caches.
Does the trailing slash matter in an hreflang URL?
Yes. For Google, https://example.com/en/pricing and https://example.com/en/pricing/ are two separate URLs, even if one redirects to the other. The URL cited in the annotation must be exactly the canonical URL of the target page, with or without a trailing slash according to the site's rule. Otherwise, the target is a redirect and the return link no longer matches.
Resources
- Google Search Central: Tell Google about localized versions of your pagedevelopers.google.com
- Next.js: metadataBasenextjs.org
- Nuxt i18n: SEO and hreflangi18n.nuxtjs.org
- Laravel: Configuring trusted proxieslaravel.com
- Symfony: How to configure Symfony to work behind a load balancer or a reverse proxysymfony.com
- Cloudflare: SSL/TLS encryption modesdevelopers.cloudflare.com
Updated on
Topic checklist (PDF)