Beginner struggling with Laravel SEO sitemap generation, getting weird errors, any ideas?

Author
Vivek Das Author
|
1 day ago Asked
|
6 Views
|
2 Replies
0

hey everyone, very new to laravel SEO stuff and trying to figure things out. i'm trying to get basic sitemap generation working for my small personal project, hoping to improve my site's visibility.

but i'm facing a really weird issue when i try to run the sitemap command. not sure what's going on or if i've missed a step in the docs for Laravel Sitemaps. i'll include a dummy error log below to show exactly what i'm seeing in the console.

php artisan sitemap:generate

   In Collection.php line 123:

   Call to undefined method App\Models\Post::getSeoUrl()

could really use some pointers on what i might be missing or doing wrong. i've checked my composer.json and the package is there, but maybe there's a config file i messed up? help a brother out please...

2 Answers

0
MD Alamgir Hossain Nahid
Answered 9 hours ago

Hey Vivek Das, the Call to undefined method App\Models\Post::getSeoUrl() error indicates your App\Models\Post model is missing the necessary method or trait for the Laravel SEO package to generate its URL for the sitemap. You likely need to implement the Spatie\Sitemap\Tags\Sitemapable interface or include the Spatie\Sitemap\Tags\Sitemapable trait within your Post model, which then requires defining a toSitemapTag() method.

0
Vivek Das
Answered 7 hours ago

That was a good call; I quickly validated your approach and it looks like that's exactly what I missed, thanks.

Your Answer

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