In this lesson we will learn to differentiate between homepage 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 setting your homepage 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.
Let's start by looking at the page template when you make your way to the Site Editor and click on Templates
you will notice Pages. The page 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 page no title, page with sidebar etc.
As you can see the Twenty Twenty-Four theme, the one which I am using, provides four extra custom page templates 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.
And then we can open up our List View and select the Group block. And there we will see the Content block or the Post Content block.
And 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.
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 home page display settings.
So let's make our way to Settings and click on Reading. And 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.
And 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 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.
And if we open up our blog page we will see that this page has been assigned to the blog home template.
And please note you will edit the content and 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 and this 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.
As this means your home navigation menu will go to the home page display you set.
Next let's talk about the index template.
The index template is used as a fall back 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 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 make our way 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 our blog page we will notice that this page has been assigned to the index template.
The fallback template or the backup template.
Next let's 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 we will 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 add and assign a custom template for our latest posts homepage or static blog page.
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 change and modify the layout of the template.
For example you can move around theme blocks such as post author, post date, post category, post tag etc.
And if you want to allow comments on your site remember to make sure you don't accidentally delete the Comments block.
The next template we would like to discuss is the 404 template.
The 404 template steps in when a page isn't found.
Remember there is no page 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 I have modified and changed the 404 template to meet my needs and to speak to my customers.
Another template to take note of is the search results template.
This template displays when a visitor performs a search on your website.
Here is my coffee shop website and if I type in the word "coffee" and then hit Ssearch I will see all the related posts with this term being displayed.
And you can of course modify this template and change how search results are displayed.
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 at the top it says archive type and then name.
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 firstly I will scroll down to all my posts and then select a post named Texture.
Now below the title we will see the date and then the author and the category namely Art.
And then below the text the tag namely Abstract.
So let's go ahead and click on the Art category.
So 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.
And below the archive type 'author' we will view all the posts written by this specific author.
And the layout of this page is of course determined by the all archives template which can be modified.
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.
So you can click on the Inserter or the plus icon next to templates
you can add a template for author archives - for all your authors or for a specific person.
You also have the option to add a category template for all your categories or for 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.
And at the bottom we'll see we can also add a custom template.
A custom template can be manually applied to any post or page.
Another template which 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 latest posts or a static homepage.
The front page template takes precedence over all templates.
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.