Powered By GitBook
URL Aliases
Site visitors like to access content from friendly and easy-to-remember URLs. Before we look at URLs in more detail, it’s important to understand GovCMS site structure. Your instructor will show you how GovCMS sites are assembled based on conditions you set.
When adding content to your site, GovCMS automatically assigns a URL alias*. A URL alias uses the following format “/sanitised-item-title”. This may be useful for many generic purposes, but you could customise the paths.
*Note! When new content type is created, the URL pattern has to be configured in order to get the automatic URL alias generate.
The Path module adds a URL ALIAS fieldset to the content creation (and editing) form so that you can set up URL aliases for your pages. This provides two main advantages: firstly, search engines give better rankings to user-friendly URLs so it’s a good SEO strategy; and secondly the URLs look better and are more intuitive for the user.
Refer to the following documentation for more information https://www.drupal.org/docs/user_guide/en/content-paths.html

Let GovCMS handle URL aliases

Each new content item has a permanent URL that uses numbers, such as node/1. You’ll see this URL in the address bar when you click the Edit tab. This link doesn’t change, even if you change the title.
When you add content, you can create a custom URL alias and override the default settings.
If you use the content's menu settings to add this to the Main menu, the link will be updated automatically:

URL Patterns and the Pathauto Module

In GovCMS 8, we can include a specific URL pattern for our content pages, perhaps based on content type.
Examples:

Exercise 7.1: URL aliases - Patterns

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]
    1.
    Add a new path alias pattern
      1.
      Go to Configuration → Search and metadata → URL aliases → Patterns
      2.
      Our new content type Job posting is not listed yet, so let’s create a new Pathauto pattern. Click the Add Pathauto pattern button.
      3.
      Select Content in the Pattern type selector.
      4.
      Select the Job Posting checkbox in the Content type selector.
      5.
      Enter Job Posting in the Label field.
      6.
      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]
      7.
      Review the values and Save the form.
Update existing paths 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.
      1.
      Click on the Bulk generate tab at the top of the Patterns admin page.
      2.
      Select Content paths
      3.
      Select Generate a URL alias for un-aliased paths only
      4.
      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.
Last modified 1yr ago