How to generate a dynamic XML sitemap in php?

You can start from here: https://support.google.com/webmasters/answer/183668.

xml-sitemap

That page is explaining the basic code of a sitemap. There is an example and what tags are required and which are optional.

To make it extremely simple, we will give you an example of an xml sitemap.
Download the file from here and open it in your html editor, notepad etc.

What you need to modify there is what’s inside the “url”, “loc” tag.

With some minor php skills, you can generate all the urls of the pages from your website, like http://yourwebsite.com/page1.html, http://yourwebsite.com/page2.html and so on. And just put each url inside the “url” and the “loc” tags.

You don’t need to add content, images, videos etc. Just the urls.

Then you copy/paste the generated urls into this xml file and submit it from Google Webmaster tools.

You can verify your xml sitemap from there. It will tell you if there are any errors or not.

You can submit the same sitemap to Bing. For YaHoo, you don’t need to worry. The search engine is actually using Bing. So just submit the xml sitemap to Bing and it will be ok with YaHoo as well.

ADD A COMMENT: