Shopify Dynamic HrefLang Tags

console.log(window.location.hostname);
if(window.location.hostname==='au.{{shop.domain}}'){
var link = document.createElement('link');
link.setAttribute("hreflang", "en-au");
link.rel = 'alternate';
link.href = 'https://au.example.com';
document.head.appendChild(link);
}else if(window.location.hostname==='{{shop.domain}}'){
var link = document.createElement('link');
link.setAttribute("hreflang", "en-us");
link.rel = 'alternate';
link.href = 'https://example.com';
document.head.appendChild(link);
}

 

Want a Fast Server Like Mine?

GET VULTR!