Defining local tasks

Let's now take a look at an example of how we can define local task links by heading back to our Hello World module. On the /hello page, let's add two local tasks--one for the regular /hello page, and the other for the configuration form where the salutation can be changed. This is a good example of using local tasks (tabs), as the configuration form is strictly related to what is on the page and is used to make changes to it.

As I mentioned, local tasks go inside a *.links.task.yml file. So, let's create one for our module with two links in it:

hello_world.page:  route_name: hello_world.hello  title: 'Hello World'  base_route: hello_world.hellohello_world.config:  route_name: hello_world.greeting_form title: 'Configuration' ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.