Frustrated: Dynamic Laravel Sitemap Not Updating Routes Correctly, Getting 404 Errors

Author
Zola Traore Author
|
2 weeks ago Asked
|
53 Views
|
2 Replies
0
man, i'm pulling my hair out trying to get this dynamic XML sitemap working right for my new Laravel app. i'm using that 'Dynamic XML Sitemap for Laravel & All Websites' tool, and it was mostly fine, but now it's just broken. the main issue is whenever i add new routes or change existing ones, the sitemap just *doesn't* update. google search console is yelling at me about tons of 404s, and i can see the old routes still in the generated sitemap file. it's like it's cached or something, but i've cleared everything. this is really affecting my laravel development efforts.

here's a snippet from the logs when it tries to hit an old route that doesn't exist anymore:
[2023-10-27 14:35:01] local.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No query results for model [App\Models\BlogPost] with id [old-route-slug] in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:470
Stack trace:
#0 /var/www/html/app/Http/Controllers/SitemapController.php(78): Illuminate\Database\Eloquent\Builder->firstOrFail()
#1 [internal function]: App\Http\Controllers\SitemapController->generate()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()
i've tried php artisan cache:clear, config:clear, route:clear, even view:clear. i've run composer dump-autoload. i've manually deleted the generated sitemap file and tried regenerating. nothing seems to force it to pick up the new routes or drop the old ones immediately. sometimes it updates after like an hour, sometimes not at all. is there some deep laravel caching i'm missing? or maybe a specific command to force the sitemap package to re-scan all routes? i'm desperate for a fix, this is killing my SEO.

thanks in advance for any help!

2 Answers

0
Isabella Williams
Answered 1 week ago

Hi Zola Traore, I understand the frustration with dynamic sitemap updates in Laravel development. The NotFoundHttpException indicates your sitemap generation isn't re-scanning current routes or database entries. Ensure you're explicitly running php artisan sitemap:generate for your Dynamic XML Sitemap for Laravel & All Websites (Auto-Updating & Future-Proof) tool, or a similar command if using alternatives like spatie/laravel-sitemap or custom scripts, to force a full rebuild and achieve better Laravel application optimization.

Did running this specific sitemap generation command resolve the 404s in Google Search Console for you?

0
Zola Traore
Answered 1 week ago

Wow, `php artisan sitemap:generate` was exactly what I needed. That command seriously saved my day, can't believe I overlooked such a basic thing. And now the 404s in Search Console are finally starting to clear up.

Your Answer

You must Log In to post an answer and earn reputation.