URL Aliases are generally the best URL for site visitors to use. However, sometimes site visitors may need an alternative URL. This may be because an incorrect URL was published in print or on another website or because you want to create a shorter URL for a marketing campaign.
Redirects are also created by GovCMS to make sure only one (usually the latest) URL alias is functional and to ensure previously created URL aliases do not return “404 Not Found” response.
Illustration of how Redirects are forwarding all traffic to the latest Alias
Tip: Redirects are generally a better option because extra URL aliases can mean you end up with duplicate content issues, which has a negative impact on SEO.
Out-of-the-box, GovCMS sites may not handle redirects the way your client would expect. Navigate to the Configuration → Search and metadata → URL Aliases then go to the Settings tab and explore how the update action of URL aliases is handled.
In this default configuration the old alias will be deleted. This may not be the best way to handle changes of URL aliases in content.
A better way to handle URL aliases is to create a redirect automatically when an URL alias is getting updated. This will ensure that links to content stay valid whenever the URL alias of a content page is changed.
Now that we’ve added a custom URL alias and all job postings inherit the common URL pattern, let’s link our breadcrumb to the URL alias and explore how we can improve the user interface by manipulating breadcrumb links.
In Unit 6 we created a View called Job Posting and added a link to the top Main Navigation menu (Exercise 6.2).
The Breadcrumb link Job Postings was added by GovCMS for you.
At the moment, when we access any of the Job Posting content, the breadcrumb does not show the link to the Job Postings page. This creates a UX problem as site visitors don’t have a visual guide of the site section they’re currently in:
We want to change the breadcrumbs so that when a Job Posting page is displayed, the breadcrumb shows the link to the parent Jobs page:
The Breadcrumb links are constructed from the URL of the current page and checking if the sub-path matches any page on the site. If it does, the system pulls the title of that page and creates a breadcrumb link.
Our parent page (Jobs) URL is /job-postings and our Job Posting content URL pattern is /jobs/[node:title]. To get the Jobs page link added to the breadcrumb, all we have to do is to change its URL from /job-postings to /jobs. This way it will natively flow into the existing URL pattern for Job Posting content type and the link will be automatically generated in the breadcrumb.
Navigate to the Structure → Views and edit our Job Postings view.
Locate Path under Page Settings (middle top section).
Edit the Path, change it to /jobs.
Save the view
Test the breadcrumb by navigating to any Job Posting content. You should now get the Job Posting link in the breadcrumb.
In this exercise we will configure automated content redirection when content alias changes.
Navigate to the Configuration → Search and metadata → URL Aliases → Settings.
Scroll down to the Update action section.
Select the option Create a new alias. Leave the existing alias functioning.
Save configuration.
Test it out. Navigate to a Page of your choice.
Note the page URL alias – you’ll need it in the next step.
Change the page title and publish the page. This should change the URL alias of the page.
Confirm that the URL alias of your page changed.
Manually enter the previous URL alias – from step 6
Confirm the page redirected to the latest URL alias – as noted in the step 8.