Simple Laravel Sitemap Generator
The crawler considers the robots attribute "noindex" as well as canonical URLs by default. No further configuration is needed to make it behave. The last modified date in the sitemap is based on the "article:modified_time" value, or alternatively, the current date. Priorities are guessed based on the depth of the page in the website.
The crawl and generation are triggered using a Laravel CLI command. This way, you can include it in your deployment steps and/or schedule regular execution. Alterrnatively, you can configure a Laravel Kernel command (more below).
You can install the package using composer:
composer require bringyourownideas/laravel-sitemap
Further details can be found on the repository. With this step the required service provider is automatically installed. If you have opted out from auto discovery you will need to install the Laravel service provider manually:
php artisan vendor:publish --provider="BringYourOwnIdeas\LaravelSitemap\SitemapServiceProvider"
To trigger the crawl and generate of the sitemap you need to run the following artisan command:
php artisan generate:sitemap
This will fetch the required resources, analyse the web-pages and write the sitemap.xml file into the "public"-directory. To regularly update it you can schedule the execution in your "app/Console/Kernel.php"-file.
Automated Updating of the sitemap.xml in Laravel
To trigger regular updates of the site you can add a trigger of the Artisan command to your Laravel console kernel. As mentioned, the file is located under "app/Console/Kernel.php". Update the "schedule"-method to enable regular updates:
* Define the application's command schedule.
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
protected function schedule(Schedule $schedule)
// generate the sitemap
The configuration added above will re-generate and publish the sitemap every night at 0:42.
More information can be found on the GitHub repository for the project: https://github.com/bringyourownideas/laravel-sitemap.