I was wondering if there was a way to link directly to a routed page. I followed the doc example with a cleaner url domain/blog/blog-post-title routed to domain/blog-post-title and when I created a link to this page with url() obviously it link the “real” url, and it’s redirected afterward.
I’m not sure this is a good think for visitors and SEO. So for the moment I construct my links with $site->url().$page->uid() but I’m not sure it’s bullet proof nor it’s a good method.
I would like to have your opinion ont this, is my method is valid, and to know if a method exists to point to the routed url (I don’t think so as the routing is done on the flight)
Last question: The routing is a 301 redirect or another kind of redirect? (in cas I forgot to reshape some URLs)
Thanks. I tried something like that before the manual construction : echo url(page($blog_post)->uri() but it threw an error with “uri on a bolean” so I gave up. What are the benefits of using the page method vs the “manual” construction?
Another solution that will work out of the box without changes in the templates: Create a page model for the blog post pages and override the url() method. Please note that this will not work if your blog posts have any kind of child page.
Did you know why the code above threw an error ? I have to call the page objet first ?
In your example, how the other pages know that url() refer to that in this case ? If I call blog_post->url() anywhere in my site / other templates, this gonna work ?