Using TextWrangler, I am trying to add an hreflang tag to each URL throughout a large sitemap.
Is there a script that can add:
<xhtml:link rel=“alternate” hreflang=“en-ca” href=“https://mywebsite.com/en_ca/” />
<xhtml:link rel=“alternate” hreflang=“en-us” href=“https://mywebsite.com/en_us/” />
After each instance in the document there is the URL tag, as seen in the below example:
https://mywebsite.com/en_ca/product-1/ 2019-09-19 daily 0.8And at the same time pull in the subfolder (/product-1/) from the URL found in the tag.
The goal would be to have each url tag look like this after:
https://mywebsite.com/en_ca/product-1/ 2019-09-19 daily 0.8Essentially:
- Input hreflang tag after tag
- Grab everything after /en_ca/ in the tag and add that after /en_ca/ and /en_us/ in the added hreflang tag as well.
I’m looking for anyone who knows of script to accomplish this, or can tell me if it is even possible to do.
Thank you.