curlychoi / laravel-sitemap
Sitemap management package using laravel facede
v1.0.0
2019-12-06 02:45 UTC
Requires (Dev)
- orchestra/testbench: ^4.0
This package is auto-updated.
Last update: 2024-05-06 12:29:29 UTC
README
This package helps you create a sitemap in your project. The Laravel facade allows you to add or remove urls from your sitemap at the location of your choice.
Installation
First, install the package via composer:
composer require curlychoi/laravel-sitemap
The package will automatically register a service provider and alias.
And to create a database to store sitemap urls, publish the migration files and run the migrate.
php artisan vendor:publish --provider="Curlychoi\LaravelSitemap\Providers\SitemapServiceProvider" --tag=migrations
php artisan migrate
Usage
Creating a sitemap url
$url = request()->getSchemeAndHttpHost() . '/posts/1'; Sitemap::put($url);
Removing a sitemap url
$url = request()->getSchemeAndHttpHost() . '/posts/1'; Sitemap::forget($url);
Sitemap url to provide in search engine webmaster tools
https://your-domain.com/sitemap.xml
This sitemap.xml is compliant with the sitemaps protocol.
Testing
With the server running you can execute the tests:
$ composer test
License
The MIT License (MIT). Please see License File for more information.