Defining and using named routes

When defining a route we can give that route a name. “Now, why would you go and do that?” you might say. Let’s think about it for a moment… If we have inside our views links that point to a certain page, and then we decide to change the url to that page, we would have to go in each view and change those links. Now, if we have a name for that route we can use that name inside our views to call for that particular route, wherever it may send us.

So, in our views, instead of using a “hard-coded” url, we can call the route’s name. Let us first define a named route inside our routes.cfg: