melbahja / seo

🐘 Simple PHP library to help developers 🍻 do better on-page SEO optimization 🤖

Home Page:https://git.io/phpseo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add link rel alternate in sitemap tag urlset ?

lutskboy opened this issue · comments

<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> <loc>https://www.example.com/english/page.html</loc> <xhtml:link rel="alternate" hreflang="de" href="https://www.example.de/deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.de/schweiz-deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/page.html"/> </url>

see https://developers.google.com/search/docs/specialty/international/localized-versions?hl=ru#sitemap

Hey,

you can use alternate method, see this for example:

$map->loc('/blog/13')->freq('monthly')->priority('0.8')->alternate("/ar/blog/13", "ar")->alternate("/de/blog/13", "de");

Thanks