https://github.com/kolirt/laravel-sitemap
🪲 Sitemap generator for Laravel projects
https://github.com/kolirt/laravel-sitemap
laravel laravel-sitemap sitemap-generator sitemap-xml
Last synced: 7 months ago
JSON representation
🪲 Sitemap generator for Laravel projects
- Host: GitHub
- URL: https://github.com/kolirt/laravel-sitemap
- Owner: kolirt
- License: mit
- Created: 2020-04-21T11:28:08.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-08T09:03:27.000Z (9 months ago)
- Last Synced: 2024-09-08T10:34:51.988Z (9 months ago)
- Topics: laravel, laravel-sitemap, sitemap-generator, sitemap-xml
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# Laravel Sitemap
Sitemap generator for Laravel projects## Structure
- [Installation](#installation)
- [Usage](#examples)
- [Web routes](#web-routes)
- [SitemapController](#sitemapcontroller)
- [FAQ](#faq)
- [License](#license)
- [Other packages](#other-packages)## Installation
```bash
$ composer require kolirt/laravel-sitemap
```## Usage
### Web routes
```php
Route::get('sitemap.xml', 'SitemapController@index');
```### SitemapController
```php
class LaravelSitemapController extends Controller
{public function index(Request $request)
{
$sitemap = new Kolirt\Sitemap\Sitemap;
$lastMode = Carbon::create(2020, 4, 21, 14, 00, 00);$sitemap->setDomain('https://site.com');
$sitemap->addUrl('', $lastMode, Kolirt\Sitemap\Sitemap::CHANGE_FREG_DAILY, 1);
$products = [1, 2, 3, 4, 5, 6];
foreach ($products as $product) {
$sitemap->addUrl('products/' . $product, $lastMode, Kolirt\Sitemap\Sitemap::CHANGE_FREG_DAILY, 0.8);
}$sitemap->addUrl('page1', $lastMode, Kolirt\Sitemap\Sitemap::CHANGE_FREG_WEEKLY, 0.6);
$sitemap->addUrl('page2', $lastMode, Sitemap::CHANGE_FREG_MONTHLY, 0.5);return $sitemap->render();
}}
```## FAQ
Check closed [issues](https://github.com/kolirt/laravel-sitemap/issues) to get answers for most asked questions## License
[MIT](LICENSE.txt)## Other packages
Check out my other packages on my [GitHub profile](https://github.com/kolirt)