Hide the page title in Drupal 8
On Drupal websites, it is standard to display the page title on each page. The page title is simply the main heading of the page, and is usually formatted with a H1 tag.
In some cases, you may not want to display the page title - the home page is a common example where you may want to hide the page title altogether. In other cases, you may want to hide the page title on a range of different pages and content types.
In Drupal 8, the page title is displayed using a block - so the simplest way to hide the page title in Drupal 8 is simply to configure the block so it is not displayed on the pages where you want to exclude it:
Simply click Configure next to the Page Title block, and you can control its display just like any other Drupal block. The example below shows how to hide the Page title for the front page (using <front> is Drupal's way for us to specify the front page of the site):
Of course, this is not the only way to hide the Page title. You could also try one of the following:
- Use a specific module, such as Exclude Page Title, which provides you with fine grained control over where the page title should and shouldn't show. Note - at the time of writing the Drupal 8 version of this module is still in alpha.
- Use CSS to set display: none on the title on those pages where it should be hidden.
- Some themes offer the option to hide the page title on the front page (although this is not the only reason to choose a theme!).
- Use modules such as Panels which allow you to disable (or override) the Page Title.
- Edit the appropriate template file in your theme (e.g. page-title.html.twig).
- Add additional instances of the Page Title block to your site, and set different visibility settings for each. Be careful to make sure that only one instance of the block shows on each page!
Join our mailing list
Our Comment Policy.
We welcome your comments and questions about this lesson. We don't welcome spam. Our readers get a lot of value out of the comments and answers on our lessons and spam hurts that experience. Our spam filter is pretty good at stopping bots from posting spam, and our admins are quick to delete spam that does get through. We know that bots don't read messages like this, but there are people out there who manually post spam. I repeat - we delete all spam, and if we see repeated posts from a given IP address, we'll block the IP address. So don't waste your time, or ours. One other point to note - if you post a link in your comment, it will automatically be deleted.
Add comment