In this exercise, we’re going to automatically assign a URL alias pattern to the Job Posting content type so that all Job posting nodes will be assigned the URL alias format - http://example.com/jobs/[node:title]
Go to Configuration → Search and metadata → URL aliases, then click on the Patterns tab.
Our new content type Job posting is not listed yet, so let’s create a new Pathauto pattern.
Click the Add Pathauto pattern button.
Select Content in the Pattern type selector.
Select the Job Posting checkbox in the Content type selector.
Enter Job Posting in the Label field.
We need to find out which token to use in the Path pattern field so that it automatically takes our Job posting title and converts it into a safe URL. To explore available tokens, click the Browse available tokens link. In the Available tokens pop-up, expand Nodes and find Title field. Copy the token provided ([node:title]) and update the Path pattern field with jobs/[node:title]
Review the values and Save the form.
Now that we’ve created the new path alias, we also want to apply this new pattern to existing content, in this case Job Posting nodes. To do this, we’ll update all nodes on the site.
Click on the Bulk generate tab at the top of the Patterns admin page.
Select Content paths.
Select Generate a URL alias for un-aliased paths only.
Click Update.
The new URL alias pattern has now been applied to existing content on your site.
To test it out, create some new Job Postings and you’ll see Pathauto automatically adding the new URL alias pattern to the pages when they’re saved.
Note: The URL alias field will only be populated after saving the content (as Draft, Needs review or Published).