https://github.com/the-3labs-team/laravel-googlenews-sitemap
🔍 A Google News Sitemap generator for Laravel.
https://github.com/the-3labs-team/laravel-googlenews-sitemap
Last synced: 7 months ago
JSON representation
🔍 A Google News Sitemap generator for Laravel.
- Host: GitHub
- URL: https://github.com/the-3labs-team/laravel-googlenews-sitemap
- Owner: The-3Labs-Team
- License: mit
- Created: 2023-06-02T19:18:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-02T08:25:02.000Z (9 months ago)
- Last Synced: 2024-11-12T23:49:08.559Z (7 months ago)
- Language: PHP
- Homepage: https://3labs.it
- Size: 164 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Google News (GNews) Sitemap
[](https://packagist.org/packages/the-3labs-team/laravel-googlenews-sitemap)
[](https://github.com/the-3labs-team/laravel-googlenews-sitemap/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/the-3labs-team/laravel-googlenews-sitemap/actions?query=workflow%3Aphpstan+branch%3Amain)
[](https://github.com/the-3labs-team/laravel-googlenews-sitemap/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://codeclimate.com/github/The-3Labs-Team/laravel-googlenews-sitemap/maintainability)
[](https://codeclimate.com/github/The-3Labs-Team/laravel-googlenews-sitemap/test_coverage)

[](https://packagist.org/packages/the-3labs-team/laravel-googlenews-sitemap)This package helps you to create a [Google News Sitemap](https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap). It is useful when you have a blog/news website and you are involved in [Google Published Center](https://publishercenter.google.com).
Don't forget to create your Google News Sitemap and submit it in [Google Search Console](https://search.google.com/search-console/about), as a standard sitemap.
## Prerequisites
- PHP 8.1 or higher
- Laravel 10.x or higher## Installation
You can install the package via composer:
```bash
composer require the-3labs-team/laravel-googlenews-sitemap
```You can publish the config file with:
```bash
php artisan vendor:publish --tag="googlenews-sitemap-config"
```This is the contents of the published config file:
```php
return [
'path' => 'public/google-news-sitemap.xml',
];
```Optionally, you can publish the views using
```bash
php artisan vendor:publish --tag="laravel-googlenews-sitemap-views"
```## Usage
You can use the package as follows:
```php
// Init the sitemap
$sitemap = LaravelGooglenewsSitemap::create();// Add urls
// $articles = App\Models\Article::wherePublished()...
foreach($articles as $article) {
$sitemap->add(
url: route('articles.show', $article->slug),
authorName: $article->authorName,
title: $article->title,
lastModificationDate: $article->updated_at,
language: 'it',
);
}// Write sitemap to disk
$sitemap->writeToDisk();
```You can use it as a scheduled command, observer etc...
**Note**: according to ([Google](https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap)), you should provide articles that are:
- No older than 2 days
- No more than 60 items## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Stefano Novelli](https://github.com/The-3Labs-Team)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.