International SEO: The use of rel=”alternate” hreflang=”x” within XML Sitemaps w/ FREE TOOL

Late last year, Google announced it’s support for a new mark-up for webpages to signal that there are multiple versions of nearly the same page that are intended to be served in different countries with different languages. If you have a group of websites targeted globally to a specific region, the information and tool that Acronym’s SEO team developed and provides below will help ensure your users (and search engine spiders) see their correct localized sites.

The mark-up rel=”alternate” tag will call out the correct country site to be served to users searching in-country. For example, the U.S. version of content will show in the U.S. search results and the FR version will show in the French search results. This concept seems elementary, but for too long Google struggled getting this right and so it was the plight of search strategists everywhere.


As an agency with ample experience working with many global enterprise clients the issue of international site-targeting is not a new one. One client in particular sells high-end fashion goods all over the world and has a handful of dedicated in-country/ in-language sites to help facilitate.

The U.S. site for this client is a real powerhouse –achieving top rankings in search results outside of the states. The U.S. site’s performance in other countries, specifically in the United Kingdom and France enacted a level of cannibalization on the country-specific sites that should be holding those top positions.

The geo-targeting setting in Webmaster Tools was long believed to be the best practice, but to no avail. Most times the US site will still rank well in place of country specific sites outside of the United States. This exact situation was plaguing our client and caused much strain to their over-arching web strategies. Not an optimal position to be in for the agency or the client. A more authoritative tactic was needed and the rel=”alternate” hreflang=”x” mark-ups proved to be the solution.

The Fix is In

First made available in December, the method for adding this markup involved wrapping the rel=”alternate” and hreflang=”x” tags around every URL on every page of your site in the head section of your HTML. An example of this code can be seen here.

This proved to be a sub-optimal solution, especially considering the size of some enterprise level sites. In addition to being a logistical nightmare, the new code could bloat a site quite easily causing sites to render slower and possibly affecting rankings by being a burden to usability.

In May, Google announced that they will accept this mark-up as special annotations added to each URL found within XML Sitemaps.  This solution seems to make a lot of sense considering the XML Sitemap already contains a list of every URL a site intends to have indexed. With the Sitemap option, the search strategist needs to map each URL to each country option with the correct country code and then apply it to the specific country site’s Sitemap. Sounds easy enough, right? Not so. There are plenty of SEOs out there working with large enterprise sites with tens, if not hundreds, of thousands of URLs to manage that understand this to be quite a cumbersome task. Keep in mind that there needs to be an annotation for every site in each Sitemap. An example guide to the annotations can be seen here.

If you’re wondering if using this mark-up is worth the efforts, the results that are possible will be immediate and overwhelmingly positive. Unlike many schema mark-up inclusions that fall short of any major impact, these international tags make a major difference to both users and search engines alike. Moreover, think of the client and all the hard work they put into translating their websites so they can serve in language pages to global customers. Wouldn’t you be upset to see the wrong country site taking the top spot in the results away from your newly minted country-specific site?


To highlight the positive punch these specialized Sitemaps can pack, we can reference the results seen for the high-end fashion client mentioned earlier. In June it became very apparent that the cannibalization was rampant. In July the new Sitemaps went live: One for the US site, one for the French site and another for the UK site. The affect was almost immediate.

The data provided below pertains to organic traffic and rankings improvements for one month.

UK Site:

UK Site Ranking Graph

Organic Traffic: +411%
#1 Rankings: +173%
Page 2 Rankings: +14%
(Note: The specialized Sitemap was the only optimization done at this time.)

French Site:

French Site Ranking Graph

Organic Traffic: +7%
#1 Rankings: +5%
Page 2 Rankings: +24%
(Note: The specialized Sitemap was the only optimization done at this time.)

Download the Free Optimized HREF Lang XML Sitemap Generator

The difficult task of actually applying the annotations as tags to the Sitemap can be a formidable one. There has always been an automated way to create XML Sitemaps from third party tools and custom scripts, but they don’t hold up to inserting the new annotations. Our team searched long and hard for a tool that would handle our many Sitemap requests but there wasn’t one readily available. So, we rolled up our sleeves and built one from scratch.

Click the button below to download the tool and follow the directions below:

hreflang sitemap generator button

Using the tool to generate optimized XML Sitemaps with rel=”alternate” hreflang=”x”:

  1. Download the tool and extract it from the contents of the .zip file into a folder.
  2. Make sure you have the XML sitemap you wish to modify saved locally. Placing it in the same directory as the tool will make it easier to use, but isn’t necessary.
  3. Open the file hreflang_gen.exe from the folder in which you extracted the zip file to and it will prompt you for the location of your input XML Sitemap.
  4. If the input XML Sitemap is in the same directory as the tool, at the prompt “Please specify the file path to your source xml sitemap” you can enter just the filename. If it is in a different directory, enter the full path to the file (e.g., C:FolderSitemap.xml). Press the Enter key.
  5. If you entered a valid path to a file, you will be prompted with the question “How many parts of the URL do you want to replace”. Enter a number equal to the number of alterations that must be made to the existing URL structure in order to change it into its international form (in most cases this value will be 1). For example, if you want to change to you would enter the value 1 (since you are only changing the 1 part “.com” to “”). Press the Enter key.
  6. Next, at the prompt “How many languages” enter a numeric value equal to the number of alternate international websites you wish to add to the sitemap (or the number of rel=”alternate” hreflang=”x” tags you will be adding per URL in your XML Sitemap). The structural changes you will make to the URL must be consistent with your other changes. If they aren’t, you can simply rerun the program again after you have made your initial changes. Press the Enter key.
  7. At the prompt “please input a part of the URL you want to replace” enter the part of the original URL you wish to change into an international URL for rel=”alternate” hreflang=”x”. Press the Enter key.
  8. For the prompt, “Please enter the #x language code”, enter the corresponding language code value you wish to put in the hreflang attribute. If you chose a value more than 1 for the prompt in Step 6, then this question will be asked the appropriate number of times. Press the Enter key.
  9. The next prompt will ask “what would you like to replace x with?” in which you should enter the appropriate replacement text corresponding to Step 7. If you chose a value more than 1 for the prompt in Step 6, then this question will be asked the appropriate number of times. Press the Enter key.
  10. The last prompt will ask you to “choose a filename to save output as *.xml”. Entering just a filename will output your optimized XML Sitemap to program directory. You can also enter a complete file path. Remember to add the .xml extension to the filename. Press the Enter key and enjoy your optimized XML Sitemap! Make sure to check the XML source to make sure that the output is correct. The XML may not display the same as the original sitemap did in your browser, but it will validate correctly within Google Webmaster Tools.
hreflang sitemap generator screenshot


hreflang generator program screenshot

For more information on how to develop and implement specialized Sitemaps as an International SEO best practice, please send Acronym an email at