In this tip I’m going to explain you we can create sitemap.xml for our Cakephp3  applications. This is very simple and easy to setup.

Step 1. Add sitemap.xml in your routes like bellow so we can redirect user to specific controller

Step 2. The load required data you want to set for sitemap eg. load list of posts you want to search engine to crawl. Also, note that we need to create a new layout for this

In my case, I create simple layout file and load content in it

Step 3. Now open file you created when created method sitemap in your controller in my case I have file name sitemap.xml inside Template/my_controller/sitemap.ctp and add bellow code or modify code according to your need

Now if everything working fine when you open your website and add this URL in our address bar (https://mysite.com/sitemap.xml) you get your page sitemap.

Hope this post helps you please like and share my blog :).