kfoobar/laravel-sitemap is a Laravel package for a laravel package for generating sitemaps.
It currently has 0 GitHub stars and 37 downloads on Packagist (latest version v1.0.0).
Install it with composer require kfoobar/laravel-sitemap.
Discover more Laravel packages by kfoobar
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel package for generating sitemaps in your application.
By default, the package generates a sitemap.xml file, but you can choose to group links into different sitemaps. If you organize URLs into multiple groups or exceed the limit set in the configuration, the package will automatically create multiple sitemap files along with an index sitemap to reference them.
Install the package via Composer:
composer require kfoobar/laravel-sitemap
Publish the configuration file:
php artisan vendor:publish --provider="KFoobar\Sitemap\SitemapServiceProvider"
The configuration file config/sitemap.php allows you to set:
This package provides two functions: add() and generate().
add() accepts three parameters:
The generate() function creates the sitemap file based on the added URLs.
Note: The priority and frequency fields are not used because Google does not consider these values.
Add URLs and generate the sitemap using the Facade:
use KFoobar\Sitemap\Facades\Sitemap;
Sitemap::add('https://example.com', now(), 'default');
Sitemap::generate();
You can also instantiate the SitemapFactory class manually. This approach gives you direct control over the instance.
use KFoobar\Sitemap\SitemapFactory;
(new SitemapFactory)
->add('https://example.com')
->add('https://example.com/about')
->generate();
use KFoobar\Sitemap\SitemapFactory;
$sitemap = new SitemapFactory;
foreach (Post::all() as $post) {
$url = route('posts.show', $post);
$lastModified = $post->updated_at->toIso8601String();
$sitemap->add($url, $lastModified);
}
$sitemap->generate();
Contributions are welcome!
The MIT License (MIT). Please see License File for more information.