Transcript
Introduction
In this lesson, we will learn to differentiate between home page display settings and the various templates that come with a block theme. In one of our previous sessions, we were introduced to page templates, their function, how to edit a template, adding a new template, and how to assign a template to a page or post. In future lessons, we will take a closer look at some of these templates individually. But let’s go ahead and gain a deep understanding of how to use the various templates that come with a block theme and set your home page display. Templates such as the pages template, index template, single posts template, 404 template, and all archives template. As a reminder, WordPress uses templates to create the layout and structure for a page or post.
Pages template
Let’s start by looking at the pages template when you make your way to the Site Editor and click on Templates. You will notice Pages. The pages template is the default template, and every new page you create will be assigned to this template. You will also possibly see other custom page templates depending on your theme, such as a page with no title, a page with a sidebar, etc. As you can see, the Twenty Twenty-Four theme, the one which I am using, provides four extra custom page templates at the bottom left, which you could use, edit, and assign to single or multiple pages. When we open the page template, we will see that our header and footer are already in place. Then, we can open our List View and select the Group block. There we will see the Content block or the Post Content block. The Post Content block pulls in the content from pages assigned to this template. Remember, we don’t add content to the page template. We only provide structure by, for example, adding a header and a footer.
Blog Home template
Next let’s return to our templates and discuss the blog home template as well as the index template. But to do that we have to also discuss the homepage display settings. So let’s make our way to Settings and click on Reading. Then, select a static home page and a static blog page. If you have selected a static home page, all your pages including your home page will be assigned to the page template. If you have selected a static blog page or posts page, your blog or posts page will be assigned to the blog home template. Let’s see this in action. On this website, I have installed and activated the Twenty Twenty-Four theme, and I have set up a static home page and a static blog page. Then we can make our way to Pages, and if we open up a homepage we will see it has been assigned to the page template. If we open our blog page, we will see that this page has been assigned to the blog home template. Please note you will edit the content, the header, and the footer of your blog page or posts page right within the blog home template. So yes, you will build your entire blog page or posts page within the template.
But what if you have selected your latest posts as your homepage display? Well, your blog home template will become your homepage. If we make our way to the Site Editor, go to pages, and at the top, we will see our homepage. In this case the blog home template is also indicated by the home icon on the left. Here is a very important tip for when you create your navigation menu for your website. So let’s make our way to our main navigation menu, and at the moment, it’s empty. Then I’ll select edit and use the sidebar settings to add my Homepage link. Here’s the tip: add the Home Link block. This means your home navigation menu will go to the home page display you set.
Index template
Next, let’s talk about the index template. The index template is used as a fallback template for all pages when a more specific template is not defined. So, it literally means that the index template will be used as a backup template if a theme has not been assigned a specific template. Let’s see this in action. On this website, I’ve installed and activated the Tove theme, and this theme actually does not have a blog home template. So, if we go to Settings and Reading, you’ll notice I’ve already set a static home page and posts page. And if we then go to pages we’ll see that our homepage has been assigned to the page template. The same as before. But if we go to our posts page or blog page, we will notice that this page has been assigned to the index template – the fallback template or the backup template.
Next, return to our Reading settings and change our homepage display to our latest posts page. Once saved, we can head to the Site Editor and see that our index template is now our homepage. As mentioned, the index template is merely a fallback template. So it is not advised to use the index template for your homepage or blog page. So, what is the best solution? It would be best to add a new template. So when we click on the plus icon next to templates we can add the blog home template if available. Or assign a custom template for our latest posts’ homepage or static blog page.
Single Posts template
Next, we move on to the single posts template. This template influences the layout of individual posts. Although we don’t add content to the single posts template, you can modify its layout. For example, you can move around theme blocks such as post author, post date, post category, post tag, etc. If you want to allow comments on your site, remember to ensure you don’t accidentally delete the Comments block.
404 template
The next template we would like to discuss is the 404 template. The 404 template steps in when a page isn’t found. Remember, no page is assigned to this template. If you want your 404 page to have a unique look and feel, you can edit the 404 template directly. In this example, you will notice that I have modified and changed the 404 template to meet my needs and speak to my customers.
Search Results template
Another template to note is the search results template. This template will be displayed when a visitor performs a search on your website. Here is my coffee shop website. If I type in the word coffee and then hit search, I will see all the related posts with this term displayed. Of course, you can modify this template and change how search results are displayed.
All archives template
The next template we will discuss is the all archives template. The all archives template displays groupings of posts by categories, tags, or archives such as author, month, or year. So, for example, if you want to see all the posts from a specific category, this template will be used. You will notice that it says archive type and then name at the top. Now, the archive type can be a category, a tag, an author, and then, of course, the name is the name of the post. Let’s visit my blog page to see how this works. So first I will scroll down to all my posts and then select a post named Texture. Below the title, we will see the date, author, and category, namely Art. And then below the text, the tag, namely Abstract. So, let’s go ahead and click on the art category. At the top, the archive type is the category, and in the name and below that, we will see all the posts within the art category. Then I will return to the post named texture and select the author. Below the archive type author, we will view all the posts written by this specific author. The layout of this page is, of course, determined by the all archives template, which can be modified.
Adding templates
But what if you wanted to create a template for a specific category or tag, or author? Well, you can do that by adding a template. If you click on the Inserter or the plus icon next to templates, you can add a template for author archives. For all you authors or a specific person. You also have the option to add a category template for all your categories or individual categories. You can also create a template for date archives or tag archives. Then you will notice you also have an option to add a new page template or a single item post template. So basically a template for a single post. At the bottom, we will see that we can also add a custom template. A custom template can be manually applied to any post or page. Another template that you can add is a front page template. Please take note the front page template will display your site’s homepage, whether it is set to display the latest posts or a static homepage. The front page template takes precedence over all templates.
Conclusion
And that’s a wrap. I trust you feel more comfortable now distinguishing between your homepage display settings as well as the various templates that form part of your theme.