How to implement hreflang

Harry Owen

Senior Technical SEO Specialist


SEO

What is hreflang?

Hreflang, or a hreflang attribute, is a language code that tells Google and some other search engines which language you are using on a specific page. The code also informs search engines if the page is aimed at a specific country and language (for example the page may be targeting French Canadians). This then helps search engines surface the correct page for that user’s language and location.

 

Why should I use hreflang?

Hreflang codes allow you to get closer to your target audience by instructing Google and other search engines which URL to surface for a specific language or region. It’s important to ensure each URL variation is unique to that specific language and country (if applicable).

 

Should I use hreflang on a CCTLD or sub-domain?

Hreflang should be used on any page that has a localized alternative even if the URL structure has been localized.

 

Does hreflang solve duplicate content?

Hreflang will not solve duplicate content, but it will help search engines decipher those URL variations which have been created to target a specific language or language and country. This is why it is essential to optimize each URL variation to the targeted language and, if applicable, country.

How to avoid common mistakes with hreflang codes

  • Make sure to always put the language code ahead of the country code
  • Show the full URL instead of using relative URL
  • Don’t use the hreflang country code on its own, as this is an optional add-on to language code
  • Make sure to always include a self-referencing hreflang tag
  • EU is not a language or country code and cannot be used in hreflang
  • US cannot be used as a language code, only a country code
  • UK is also not a language or country code, en-GB is the most commonly used to target UK users
  • If you are just targeting language, don’t include country code, you are making more work for yourself and could end up with duplicate content issues.

How to implement hreflang code

There are three ways you can implement hreflang on your website.

 

HTML

Adding <rel=“alternate” hreflang=“en-GB” href=“https://www.example.co.uk”/> to your page header will communicate every localized variation of a page to search engines. This is a very common approach to implementing hreflang.

 

HTTP headers

HTTP headers can be used to communicate which language and country URL version the search engine should select. This is most common in those pages without HTML files, such as PDFs. For a page in the UK and US, it would look something like this: Link: <url1>; rel=“alternate” ; hreflang=“en-GB”,  <url2>; rel=“alternate” ; hreflang=“en-US” , …

 

Sitemap

You can also use a XML sitemap to tell search engines which localised URL is most relevant to the user. To implement a hreflang sitemap, you will need to add <loc> to specify a URL and include <xhtml:link> for each of the local variations of the URL.

 

If you were targeting English, French and German users, your code would look like this:

<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″
xmlns:xhtml=”http://www.w3.org/1999/xhtml”>
<url>
<loc>https://www.example.com/en</loc>
<xhtml:link
rel=”alternate”
hreflang=”fr”
href=”https://www.example.com/fr”>
<xhtml:link
rel=”alternate”
hreflang=”de”
href=”https://www.example.com/de”/>
</url>

 

Each of these methods dictate the correct language and country code for each variation of your URL. Below, we have put a list together of all the possible language and country codes you may need when adding hreflang to your website.

Hreflang Language Codes

Here is a list of applicable language codes, also referred to as ISO 639 codes. These can be used to ensure your hreflang implementation has been carried our correctly.

 

Language 2-letter ISO Code
Abkhaz ab
Afar aa
Afrikaans af
Akan ak
Albanian sq
Amharic am
Arabic ar
Aragonese an
Armenian hy
Assamese as
Avaric av
Avestan ae
Aymara ay
Azerbaijani az
Bambara bm
Bashkir ba
Basque eu
Belarusian be
Bengali, Bangla bn
Bihari bh
Bislama bi
Bosnian bs
Breton br
Bulgarian bg
Burmese my
Catalan, Valencian ca
Chamorro ch
Chechen ce
Chichewa, Chewa, Nyanja ny
Chinese zh
Chuvash cv
Cornish kw
Corsican co
Cree cr
Croatian hr
Czech cs
Danish da
Divehi, Dhivehi, Maldivian dv
Dutch nl
Dzongkha dz
English en
Esperanto eo
Estonian et
Ewe ee
Faroese fo
Fijian fj
Finnish fi
French fr
Fula, Fulah, Pulaar, Pular ff
Galician gl
Georgian ka
German de
Greek (modern) el
Guaraní gn
Gujarati gu
Haitian, Haitian Creole ht
Hausa ha
Hebrew (modern) he
Herero hz
Hindi hi
Hiri Motu ho
Hungarian hu
Interlingua ia
Indonesian id
Interlingue ie
Irish ga
Igbo ig
Inupiaq ik
Ido io
Icelandic is
Italian it
Inuktitut iu
Japanese ja
Javanese jv
Kalaallisut, Greenlandic kl
Kannada kn
Kanuri kr
Kashmiri ks
Kazakh kk
Khmer km
Kikuyu, Gikuyu ki
Kinyarwanda rw
Kyrgyz ky
Komi kv
Kongo kg
Korean ko
Kurdish ku
Kwanyama, Kuanyama kj
Latin la
Luxembourgish, Letzeburgesch lb
Ganda lg
Limburgish, Limburgan, Limburger li
Lingala ln
Lao lo
Lithuanian lt
Luba-Katanga lu
Latvian lv
Manx gv
Macedonian mk
Malagasy mg
Malay ms
Malayalam ml
Maltese mt
Māori mi
Marathi (Marāṭhī) mr
Marshallese mh
Mongolian mn
Nauru na
Navajo, Navaho nv
Northern Ndebele nd
Nepali ne
Ndonga ng
Norwegian Bokmål nb
Norwegian Nynorsk nn
Norwegian no
Nuosu ii
Southern Ndebele nr
Occitan oc
Ojibwe, Ojibwa oj
Old Church Slavonic, Church Slavonic, Old Bulgarian cu
Oromo om
Oriya or
Ossetian, Ossetic os
Panjabi, Punjabi pa
Pāli pi
Persian (Farsi) fa
Polish pl
Pashto, Pushto ps
Portuguese pt
Quechua qu
Romansh rm
Kirundi rn
Romanian ro
Russian ru
Sanskrit (Saṁskṛta) sa
Sardinian sc
Sindhi sd
Northern Sami se
Samoan sm
Sango sg
Serbian sr
Scottish Gaelic, Gaelic gd
Shona sn
Sinhala, Sinhalese si
Slovak sk
Slovene sl
Somali so
Southern Sotho st
Spanish, Castilian es
Sundanese su
Swahili sw
Swati ss
Swedish sv
Tamil ta
Telugu te
Tajik tg
Thai th
Tigrinya ti
Tibetan Standard, Tibetan, Central bo
Turkmen tk
Tagalog tl
Tswana tn
Tonga (Tonga Islands) to
Turkish tr
Tsonga ts
Tatar tt
Twi tw
Tahitian ty
Uyghur, Uighur ug
Ukrainian uk
Urdu ur
Uzbek uz
Venda ve
Vietnamese vi
Volapük vo
Walloon wa
Welsh cy
Wolof wo
Western Frisian fy
Xhosa xh
Yiddish yi
Yoruba yo
Zhuang, Chuang za
Zulu zu

 

Hreflang Country Codes

Below is a list of applicable hreflang country codes, also referred to as ISO 3166-1 codes. These should be used when you are not only targeting a certain language, but also a specific country.

 

Country 2-character ISO Code
Afghanistan AF
Åland Islands AX
Albania AL
Algeria DZ
American Samoa AS
Andorra AD
Angola AO
Anguilla AI
Antarctica AQ
Antigua and Barbuda AG
Argentina AR
Armenia AM
Aruba AW
Australia AU
Austria AT
Azerbaijan AZ
Bahamas BS
Bahrain BH
Bangladesh BD
Barbados BB
Belarus BY
Belgium BE
Belize BZ
Benin BJ
Bermuda BM
Bhutan BT
Bolivia, Plurinational State of BO
Bonaire, Sint Eustatius and Saba BQ
Bosnia and Herzegovina BA
Botswana BW
Bouvet Island BV
Brazil BR
British Indian Ocean Territory IO
Brunei Darussalam BN
Bulgaria BG
Burkina Faso BF
Burundi BI
Cambodia KH
Cameroon CM
Canada CA
Cabo Verde CV
Cayman Islands KY
Central African Republic CF
Chad TD
Chile CL
China CN
Christmas Island CX
Cocos (Keeling) Islands CC
Colombia CO
Comoros KM
Congo CG
Congo, the Democratic Republic of the CD
Cook Islands CK
Costa Rica CR
Côte d’Ivoire CI
Croatia HR
Cuba CU
Curaçao CW
Cyprus CY
Czech Republic CZ
Denmark DK
Djibouti DJ
Dominica DM
Dominican Republic DO
Ecuador EC
Egypt EG
El Salvador SV
Equatorial Guinea GQ
Eritrea ER
Estonia EE
Ethiopia ET
Falkland Islands (Malvinas) FK
Faroe Islands FO
Fiji FJ
Finland FI
France FR
French Guiana GF
French Polynesia PF
French Southern Territories TF
Gabon GA
Gambia GM
Georgia GE
Germany DE
Ghana GH
Gibraltar GI
Greece GR
Greenland GL
Grenada GD
Guadeloupe GP
Guam GU
Guatemala GT
Guernsey GG
Guinea GN
Guinea-Bissau GW
Guyana GY
Haiti HT
Heard Island and McDonald Islands HM
Holy See (Vatican City State) VA
Honduras HN
Hong Kong HK
Hungary HU
Iceland IS
India IN
Indonesia ID
Iran, Islamic Republic of IR
Iraq IQ
Ireland IE
Isle of Man IM
Israel IL
Italy IT
Jamaica JM
Japan JP
Jersey JE
Jordan JO
Kazakhstan KZ
Kenya KE
Kiribati KI
Korea, Democratic People’s Republic of KP
Korea, Republic of KR
Kuwait KW
Kyrgyzstan KG
Lao People’s Democratic Republic LA
Latvia LV
Lebanon LB
Lesotho LS
Liberia LR
Libya LY
Liechtenstein LI
Lithuania LT
Luxembourg LU
Macao MO
Macedonia, the former Yugoslav Republic of MK
Madagascar MG
Malawi MW
Malaysia MY
Maldives MV
Mali ML
Malta MT
Marshall Islands MH
Martinique MQ
Mauritania MR
Mauritius MU
Mayotte YT
Mexico MX
Micronesia, Federated States of FM
Moldova, Republic of MD
Monaco MC
Mongolia MN
Montenegro ME
Montserrat MS
Morocco MA
Mozambique MZ
Myanmar MM
Namibia NA
Nauru NR
Nepal NP
Netherlands NL
New Caledonia NC
New Zealand NZ
Nicaragua NI
Niger NE
Nigeria NG
Niue NU
Norfolk Island NF
Northern Mariana Islands MP
Norway NO
Oman OM
Pakistan PK
Palau PW
Palestine, State of PS
Panama PA
Papua New Guinea PG
Paraguay PY
Peru PE
Philippines PH
Pitcairn PN
Poland PL
Portugal PT
Puerto Rico PR
Qatar QA
Réunion RE
Romania RO
Russian Federation RU
Rwanda RW
Saint Barthélemy BL
Saint Helena, Ascension and Tristan da Cunha SH
Saint Kitts and Nevis KN
Saint Lucia LC
Saint Martin (French part) MF
Saint Pierre and Miquelon PM
Saint Vincent and the Grenadines VC
Samoa WS
San Marino SM
Sao Tome and Principe ST
Saudi Arabia SA
Senegal SN
Serbia RS
Seychelles SC
Sierra Leone SL
Singapore SG
Sint Maarten (Dutch part) SX
Slovakia SK
Slovenia SI
Solomon Islands SB
Somalia SO
South Africa ZA
South Georgia and the South Sandwich Islands GS
South Sudan SS
Spain ES
Sri Lanka LK
Sudan SD
Suriname SR
Svalbard and Jan Mayen SJ
Swaziland SZ
Sweden SE
Switzerland CH
Syrian Arab Republic SY
Taiwan, Province of China TW
Tajikistan TJ
Tanzania, United Republic of TZ
Thailand TH
Timor-Leste TL
Togo TG
Tokelau TK
Tonga TO
Trinidad and Tobago TT
Tunisia TN
Turkey TR
Turkmenistan TM
Turks and Caicos Islands TC
Tuvalu TV
Uganda UG
Ukraine UA
United Arab Emirates AE
United Kingdom GB
United States US
United States Minor Outlying Islands UM
Uruguay UY
Uzbekistan UZ
Vanuatu VU
Venezuela, Bolivarian Republic of VE
Viet Nam VN
Virgin Islands, British VG
Virgin Islands, U.S. VI
Wallis and Futuna WF
Western Sahara EH
Yemen YE
Zambia ZM
Zimbabwe ZW

 

Discover how our international SEO team can take your website globalFind out more


"