Sitemap issueshttps://gitlab.com/Laravelium/Sitemap/-/issues2019-12-16T23:44:16Zhttps://gitlab.com/Laravelium/Sitemap/-/issues/160Change filesystem2019-12-16T23:44:16ZRumen DamyanovChange filesystem*Created by: pierrocknroll*
Hi,
I see that in your code you use `$this->file->put($file, $data['content'])` to save the sitemap.xml in the framework filesystem, but how can I change it to save for exemple on S3 ?
Thanks*Created by: pierrocknroll*
Hi,
I see that in your code you use `$this->file->put($file, $data['content'])` to save the sitemap.xml in the framework filesystem, but how can I change it to save for exemple on S3 ?
Thankshttps://gitlab.com/Laravelium/Sitemap/-/issues/156Doc Suggestion: Generating Large Sitemaps Through a Command2018-08-25T12:27:56ZRumen DamyanovDoc Suggestion: Generating Large Sitemaps Through a Command*Created by: dingman*
I made some modifications to the documented example for large sitemaps and wanted to share. I used 10,000 instead of 50,000 because my VM couldn't handle 50,000 in one shot. Certainly welcome to feedback on it, I'm...*Created by: dingman*
I made some modifications to the documented example for large sitemaps and wanted to share. I used 10,000 instead of 50,000 because my VM couldn't handle 50,000 in one shot. Certainly welcome to feedback on it, I'm a novice developer.
```
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class GenerateSitemaps extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'generate:sitemap';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate XML sitemaps';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$start = microtime(true);
// generate new sitemap file
$sitemap = \App::make('sitemap');
$counter = 0;
$sitemapCounter = 0;
\App\Product::with('details')
->orderBy('id','asc')
->chunk(10000, function ($products) use (&$sitemap, &$counter, &$sitemapCounter) {
foreach ($products as $p) {
if ($counter == 10000) {
// generate new sitemap file
$sitemap->store('xml', 'sitemap-' . $sitemapCounter);
// add the file to the sitemaps array
$sitemap->addSitemap(secure_url('sitemap-' . $sitemapCounter . '.xml'));
// reset items array (clear memory)
$sitemap->model->resetItems();
// reset the counter
$counter = 0;
// count generated sitemap
$sitemapCounter++;
}
// add product to items array
$p->freq = 'daily';
$p->priority = '0.9';
$p->timestamp = $p->details->pluck('updated_at')->sortByDesc('updated_at')->first();
$p->permalink = route('product', $p->slug);
$sitemap->add($p->permalink, $p->timestampe, $p->priority, $p->freq);
// count number of elements
$counter++;
}
});
// you need to check for unused items
if (!empty($sitemap->model->getItems())) {
// generate sitemap with last items
$sitemap->store('xml', 'sitemap-' . $sitemapCounter);
// add sitemap to sitemaps array
$sitemap->addSitemap(secure_url('sitemap-' . $sitemapCounter . '.xml'));
// reset items array
$sitemap->model->resetItems();
}
// generate new sitemapindex that will contain all generated sitemaps above
$sitemap->store('sitemapindex', 'sitemap') ;
$end = microtime(true);
$this->info("Took ".($end - $start) ." seconds to complete\n");
}
}
```Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/162Method render() does not work after using the store() method2018-09-20T13:39:28ZLuís GonçalvesMethod render() does not work after using the store() methodHello,
I'm using the render() method after storing the xml file, using store(), and the rendered page is showing an empty xml. Using the default configs.
The xml file is being stored correctly, it has all the info it is supposed to...Hello,
I'm using the render() method after storing the xml file, using store(), and the rendered page is showing an empty xml. Using the default configs.
The xml file is being stored correctly, it has all the info it is supposed to have, but then the render() is failing.
Simple code example:
public function staticPages()
{
$sitemap = app()->make('sitemap');
$sitemap->add(url('about-us'), date('Y-m-d H:i:s'), '1.0', 'yearly');
$sitemap->store('xml', 'sitemap-static-pages');
return $sitemap->render('xml');
}
If i remove the store() than the render() works fine.
This code used to work with the with the previous package (https://github.com/RoumenDamianoff/laravel-sitemap).
Any suggestions?Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/163Can't Render with custom path style2018-09-25T03:34:30ZKhánh Vũ DuyCan't Render with custom path style![Screen_Shot_2018-09-25_at_10.30.52_AM](/uploads/167619a5317b819c382ff1c3c3e16db6/Screen_Shot_2018-09-25_at_10.30.52_AM.png)
![Screen_Shot_2018-09-25_at_10.31.01_AM](/uploads/d5f4ee51c126241e68cebf53309b5a16/Screen_Shot_2018-09-25_at_10...![Screen_Shot_2018-09-25_at_10.30.52_AM](/uploads/167619a5317b819c382ff1c3c3e16db6/Screen_Shot_2018-09-25_at_10.30.52_AM.png)
![Screen_Shot_2018-09-25_at_10.31.01_AM](/uploads/d5f4ee51c126241e68cebf53309b5a16/Screen_Shot_2018-09-25_at_10.31.01_AM.png)
Custom path style alway "null".https://gitlab.com/Laravelium/Sitemap/-/issues/165'/sitemap' vs '/sitemap.xml' in the route2019-09-03T19:27:23ZKiril Lukiyan'/sitemap' vs '/sitemap.xml' in the routeHi,
I finally figured out how everything works, and now I'm building my dynamic sytemap script (i'm having all the code in controller, instead of routes file).
My last consern is whether to use `/sitemap` or `/sitemap.xml` in the route....Hi,
I finally figured out how everything works, and now I'm building my dynamic sytemap script (i'm having all the code in controller, instead of routes file).
My last consern is whether to use `/sitemap` or `/sitemap.xml` in the route.
Per the guide it is `/sitemap` but I noticed that a general standard is to store it with extension in `robots.txt`.
Is there any difference for the search engines? Should I better make it with .xml at the end of the route, or it's better without? and why?
thank you for explaining.Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/166Is render() works with addSitemap()2019-09-03T20:15:41Zjano karyIs render() works with addSitemap()Can I dynamically create an index sitemap for all parent sitemap using addSitemap() and then render() it?
something like:
```
$sitemap->addSitemap(route('sitemaps-posts'));
$sitemap->addSitemap(route('sitemaps-pages'));;
return $sitema...Can I dynamically create an index sitemap for all parent sitemap using addSitemap() and then render() it?
something like:
```
$sitemap->addSitemap(route('sitemaps-posts'));
$sitemap->addSitemap(route('sitemaps-pages'));;
return $sitemap->render();
```Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/167Return $this on addSitemap() function2019-09-03T20:16:41ZJeff OchoaReturn $this on addSitemap() functionThis is just a code-improvement suggestion. If Return the current sitemap instance from the `addSitemap` function, you could use chained methods instead of re-writing the same variable over and over, like so:
As it is now:
```php
Class ...This is just a code-improvement suggestion. If Return the current sitemap instance from the `addSitemap` function, you could use chained methods instead of re-writing the same variable over and over, like so:
As it is now:
```php
Class SiteMapController {
public function __invoke($loc, $lastmod = null)
{
$sitemap = app()->make('sitemap');
$sitemap->addSitemap(url('sitemap/categories'));
$sitemap->addSitemap(url('sitemap/tags'));
$sitemap->addSitemap(url('sitemap/content'));
$sitemap->addSitemap(url('sitemap/categories'));
return $sitemap->render('sitemapindex');
}
}
```
Returning `$this` from the `addSitemap()` function:
```php
Class SiteMapController {
public function __invoke($loc, $lastmod = null)
{
return app()->make('sitemap')
->addSitemap(url('sitemap/categories'))
->addSitemap(url('sitemap/tags'))
->addSitemap(url('sitemap/content'))
->addSitemap(url('sitemap/categories'))
->render('sitemapindex');
}
}
```Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/171Undefined index: priority2019-02-19T22:42:01ZJordaneUndefined index: priorityHi,
First of all thanks for your awesome job, you save me lot of times since many years for get a clean sitemap.
Since few days, SEMRush and me are getting a weird error "Undefined index: priority". In the file xml.php at line 21.
Thi...Hi,
First of all thanks for your awesome job, you save me lot of times since many years for get a clean sitemap.
Since few days, SEMRush and me are getting a weird error "Undefined index: priority". In the file xml.php at line 21.
This error appear randomly. I dont understand why im getting this error sometimes. I have set the priority correctly each time I add a new entry, like : "$sitemap->add(route('server.create', $top->subdomain), null, 1, 'monthly');".
I think this is an issue but why its happens now and not before ? I'm using the v2.6.5 from old namespace roumen/sitemap on github. But I saw the source code here about xml.php there's still the line 21 about priority without isset checks.
Have you an idea about this issue ? Thanks by advance.https://gitlab.com/Laravelium/Sitemap/-/issues/173Apparent error2019-03-19T10:30:31Zjim15061Apparent errorI have installed this and generated a controller (SitemapController) with just one function index. I call this from the web.php.
Here is the controller:
`<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Spatie\S...I have installed this and generated a controller (SitemapController) with just one function index. I call this from the web.php.
Here is the controller:
`<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Spatie\Sitemap\SitemapGenerator;
class SitemapController extends Controller
{
public function index()
{
session()->flash('success',"your sitemap has been generated and is in your site's public directory");
return redirect()->route('dashboard');
}
}`
When I try running this I get
> Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'App\Http\Controllers\App' not foundhttps://gitlab.com/Laravelium/Sitemap/-/issues/176Duplicate this project on Github2019-09-03T19:26:48Zmohsen shafieimohsen.sh12@hotmail.comDuplicate this project on GithubGitlab is not accessible in some countries, please make a mirror in GithubGitlab is not accessible in some countries, please make a mirror in GithubRumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/178lastmod date is wrong in the XML2019-05-14T17:06:00ZAfonso Gomeslastmod date is wrong in the XMLCreated the generators on a controller so I have this:
```
public function especies ()
{
// Criar o sitemap
$sitemap = App::make('sitemap');
// Especificar cache
$sitemap->setCache('laravel.site...Created the generators on a controller so I have this:
```
public function especies ()
{
// Criar o sitemap
$sitemap = App::make('sitemap');
// Especificar cache
$sitemap->setCache('laravel.sitemap-especies', 3600);
// Receber todas as noticias da Base de dados
$especies = DB::table('especies')->orderBy('created_at', 'desc')->get();
// Adicionar items
foreach($especies as $especie)
{
$data = $especie->updated_at !== null ? $especie->updated_at : $especie->created_at;
$sitemap->add($this->appUrl . '/jardimbotanico/especie/' . $especie->slug, $data, '0.75', 'weekly');
}
// Preparar a visualização
$render = $sitemap->render('xml','sitemap-especies');
// Salvar o sitemap
$sitemap->store('xml', 'sitemap-especies');
// Devolver a visualização
return $render;
}
```
But on the generated XML I get this
```
<loc>https://[OMMITED]/jardimbotanico/especie/Briza_maxima</loc>
<priority>0.75</priority>
<lastmod>1970-01-01T01:00:00+01:00</lastmod>
<changefreq>weakly</changefreq>
</url>
```
Why is the lastmod wrong? The $data variable is correct on the Controllerhttps://gitlab.com/Laravelium/Sitemap/-/issues/179Generate from Url2019-06-16T01:24:03ZBiagio Spit.Generate from UrlHello im looking to create a sitemap with the exist Route, and remove the for example the route that require param,
i have this route:
`
software
software/{name}
movies
movies/{name}
apk
apk/{name}
pc-games
`
i would like to make all s...Hello im looking to create a sitemap with the exist Route, and remove the for example the route that require param,
i have this route:
`
software
software/{name}
movies
movies/{name}
apk
apk/{name}
pc-games
`
i would like to make all sitemap without the param so:
`
software
movies
apk
pc-games
`
it is possible make something like it dynamic, instead of always write a new line ?
i write this code for get all route
`
$routeCollection = Route::getRoutes();
foreach ($routeCollection as $value) {
echo $value->uri().'<br>';
}
this code atm is in route for know the "list"
`
Thanks for support, and good jobhttps://gitlab.com/Laravelium/Sitemap/-/issues/181Use contracts type restrictions instead of implementation2019-09-03T20:15:02ZPaul KlimovUse contracts type restrictions instead of implementationLibrary should accept any implementation of the Laravel contracts (interfaces) instead of particular implementation for the internal dependencies.
To be more specific class `Sitemap` should accept `Illuminate\Contracts\Config\Repository`...Library should accept any implementation of the Laravel contracts (interfaces) instead of particular implementation for the internal dependencies.
To be more specific class `Sitemap` should accept `Illuminate\Contracts\Config\Repository` instead of `Illuminate\Config\Repository`, `Illuminate\Contracts\Cache\Repository` instead of `Illuminate\Cache\Repository` and so on.
Such policy allows usage of any even non-standard implementation of the config repository, cache and other components.Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/183Cache is not working with BIG-sitemaps2019-08-10T19:22:36ZAbdelrahman BadreldeenCache is not working with BIG-sitemapsWhy cache is not working here ?
`$sitemap->isCached()` value always `false`
Simple code example:
public function generate()
{
$sitemap = App::make('sitemap');
$sitemap->setCache('sitemap.cache', 500);
...Why cache is not working here ?
`$sitemap->isCached()` value always `false`
Simple code example:
public function generate()
{
$sitemap = App::make('sitemap');
$sitemap->setCache('sitemap.cache', 500);
if (!$sitemap->isCached()) {
$products = DB::table('products')->orderBy('created_at', 'desc')->get();
$counter = 0;
$sitemapCounter = 0;
foreach ($products as $p) {
if ($counter == 50000) {
$sitemap->store('xml', 'sitemap-' . $sitemapCounter);
$sitemap->addSitemap(secure_url('sitemap-' . $sitemapCounter . '.xml'));
$sitemap->model->resetItems();
$counter = 0;
$sitemapCounter++;
}
$sitemap->add($p->slug, $p->modified, $p->priority, $p->freq);
$counter++;
}
if (!empty($sitemap->model->getItems())) {
$sitemap->store('xml', 'sitemap-' . $sitemapCounter);
$sitemap->addSitemap(secure_url('sitemap-' . $sitemapCounter . '.xml'));
$sitemap->model->resetItems();
}
}
return $sitemap->render('sitemapindex');
}https://gitlab.com/Laravelium/Sitemap/-/issues/184Create sitemap without style2019-09-03T19:24:44ZAsh PrescottCreate sitemap without styleHI,
I was wondering if it was possible to create an .xml sitemap without any style applied?
The style that is applied by default is causing issues with my .xml file being read by external services, as I believe that the sitemap is best ...HI,
I was wondering if it was possible to create an .xml sitemap without any style applied?
The style that is applied by default is causing issues with my .xml file being read by external services, as I believe that the sitemap is best being published in https://www.sitemaps.org/protocol.html format.
ThanksRumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/185Add support for Laravel 6.02019-09-03T20:14:50ZAlvin BakkerAdd support for Laravel 6.0Please add Laravel 6.0
ThanksPlease add Laravel 6.0
ThanksRumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/187Class sitemap does not exist2020-03-17T21:09:16ZAbanoub IstfanousClass sitemap does not existeverything works fine on localhost but on server says this error
Class sitemap does not exist
```
Route::get('sitemap', function () {
// create new sitemap object
$sitemap = App::make('sitemap');
// set cache key (string), durati...everything works fine on localhost but on server says this error
Class sitemap does not exist
```
Route::get('sitemap', function () {
// create new sitemap object
$sitemap = App::make('sitemap');
// set cache key (string), duration in minutes (Carbon|Datetime|int), turn on/off (boolean)
// by default cache is disabled
$sitemap->setCache('laravel.sitemap', 60);
// check if there is cached sitemap and build new only if is not
if (!$sitemap->isCached()) {
// add item to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to('/'), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');
// add item with translations (url, date, priority, freq, images, title, translations)
$translations = [
['language' => 'fr', 'url' => URL::to('pageFr')],
['language' => 'de', 'url' => URL::to('pageDe')],
['language' => 'bg', 'url' => URL::to('pageBg')],
];
$sitemap->add(URL::to('pageEn'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', [], null, $translations);
// add item with images
$images = [
['url' => URL::to('images/pic1.jpg'), 'title' => 'Image title', 'caption' => 'Image caption', 'geo_location' => 'Plovdiv, Bulgaria'],
['url' => URL::to('images/pic2.jpg'), 'title' => 'Image title2', 'caption' => 'Image caption2'],
['url' => URL::to('images/pic3.jpg'), 'title' => 'Image title3'],
];
$sitemap->add(URL::to('post-with-images'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', $images);
// get all posts from db
$posts = DB::table('projects')->orderBy('created_at', 'desc')->get();
$services = DB::table('services')->orderBy('created_at', 'desc')->get();
$users = DB::table('users')->orderBy('created_at', 'desc')->get();
// add every post to the sitemap
foreach ($posts as $post) {
$sitemap->add('/project/' . $post->id);
}
foreach ($services as $post) {
$sitemap->add('/service/' . $post->id);
}
foreach ($users as $post) {
$sitemap->add('/users/' . $post->username);
}
}
// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
return $sitemap->render('xml');
});
```
![Whoops__There_was_an_error._2019-12-07_23-16-28](/uploads/f330ba04e0a113ca05a3dd138554f406/Whoops__There_was_an_error._2019-12-07_23-16-28.png)https://gitlab.com/Laravelium/Sitemap/-/issues/188Add support for Laravel 7.02020-03-21T19:26:16ZWuchnaAdd support for Laravel 7.0Please add support for Laravel 7.0. thanks.Please add support for Laravel 7.0. thanks.Rumen DamyanovRumen Damyanovhttps://gitlab.com/Laravelium/Sitemap/-/issues/189This archive has been requested too many times. Try again later - when retrie...2020-04-29T22:13:54ZBamieThis archive has been requested too many times. Try again later - when retrieving this repository in session-less environmentsee in incognito/private window: https://gitlab.com/api/v4/projects/Laravelium%2FSitemap/repository/archive.zip
It shows this error: `{"message":{"error":"This archive has been requested too many times. Try again later."}}`
This error ...see in incognito/private window: https://gitlab.com/api/v4/projects/Laravelium%2FSitemap/repository/archive.zip
It shows this error: `{"message":{"error":"This archive has been requested too many times. Try again later."}}`
This error is halting our complete ci-cd process due to this error occurring in the pipeline :(https://gitlab.com/Laravelium/Sitemap/-/issues/192sitemap created file but don't have any element2020-04-11T14:22:25ZThanh Le Dinh Hoaisitemap created file but don't have any elementi use laravel 6x and use command to create an sitemap file but don't have data
My code:
`<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App;
use DB;
use Carbon\Carbon;
use App\Model\Books;
use App\Model\Cate...i use laravel 6x and use command to create an sitemap file but don't have data
My code:
`<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App;
use DB;
use Carbon\Carbon;
use App\Model\Books;
use App\Model\Category;
use App\Model\BookDetails;
class CreateSiteMap extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sitemap:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create an sitemap';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// create new sitemap object
$sitemap = App::make("sitemap");
$date = Carbon::now();
//add items to the sitemap (url, date, priority, freq)
$sitemap->add(\URL::to('/'), $date, '1.0', 'daily');
// $books = DB::table('tbl_books')->orderBy('created_at', 'desc')->get();
$books = Books::orderBy('created_at', 'desc')->get();
foreach ($books as $item)
{
$sitemap->add(route('getDetail', ['id'=>$item->book_id, 'slug'=>$item->book_name_slug]), $item->updated_at, '0.9', 'daily');
}
// generate your sitemap (format, filename)
$sitemap->store('xml', 'sitemap');
}
}
`
and here is result:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/vendor/sitemap/styles/xml.xsl" type="text/xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
</urlset>
which way i wronghttps://gitlab.com/Laravelium/Sitemap/-/issues/193Too Many Requests2020-04-17T16:34:51ZHieu LuongToo Many Requests Installing laravelium/sitemap (v6.0.1): Downloading (failed) Failed to download laravelium/sitemap from dist: The "https://gitlab.com/api/v4/projects/Laravelium%2FSitemap/repository/archive.zip?sha=2b8e3b9f3ccd9ca7cdd3c21dcecf722eb12... Installing laravelium/sitemap (v6.0.1): Downloading (failed) Failed to download laravelium/sitemap from dist: The "https://gitlab.com/api/v4/projects/Laravelium%2FSitemap/repository/archive.zip?sha=2b8e3b9f3ccd9ca7cdd3c21dcecf722eb1275d49" file could not be downloaded (HTTP/1.1 429 Too Many Requests)
Now trying to download from source