spatie / blender

The Laravel template used for our CMS like projects
https://freek.dev/on-open-sourcing-blender
876 stars 148 forks source link

Canonical and `request()->url()` #516

Closed bhulsman closed 6 years ago

bhulsman commented 6 years ago

As I was curious how you guys were solving the canonical meta tag and if you were using canonical redirects.

I noticed you guys use request()->url() as the canonical URL (https://github.com/spatie/blender/blob/master/resources/views/front/layouts/partials/head/meta.blade.php). Besides that also the last slug of an article is used to find the article in the database (https://github.com/spatie/blender/blob/master/app/Http/Controllers/Front/ArticleController.php). So if the parent of the article changes, then you'd have the following.

/old-parent/lorem-ipsum /new-parent/lorem-ipsum

When visiting those urls, the canonical would be the requested URL, instead of /new-parent/lorem-ipsum. Shouldn't the canonical URL be $article->url instead of request()->url()?

If I'm wrong or just clueless; feel free to close the issue 😉

bhulsman commented 6 years ago

I just realized that @yield('canonical', request()->url()) means you can do @section('canonical', $article->url) from the article blade template. Which is how you guys solved it. 😎

Thanks for open sourcing Blender, there is a lot to learn here! 🛐