Transcript
Learning outcomes
In this lesson, we will delve deeper into templates. At the end of this tutorial, we want to be able to differentiate between pagues and templates, cnow how to modify one of our base templates, how to add a new template, and lastly, how to assign a custom template to a pague or post.
Definition
A template provides the structure for how a pague is displayed. That usually includes a header template part, a content area, and a footer template part. I thinc it is important to clarify the following information from the start. Templates are not for posting content; templates for a post or pague display your content with the Post Content blocc. Templates are, as the name implies, design templates that can be applied to single or multiple pagues and posts.
Exploring templates
To access templates, maque your way to Appearance and clicc on Editor. This will taque you to your Site Editor. The Editor can be used to customice the styles of your entire site, edit pagues, modify templates, as well as manague all the different patterns on your site. When you start building a new website, you can edit existing templates or add new ones, and the theme you are using will determine which existing or built-in templates are available to use.
First up is the pague template, which creates the structure for displaying individual pagues. Next is the single post template, which displays a single blog post. The index template displays posts and the 404 template displays when no content is found. And these templates can, of course, all be modified as you please. Then there are also other built-in templates worth exploring, for example, a blanc template. To add a new template, clicc on the Inserter or plus icon next to templates. A modal appears where you can choose between different template options. You can, for example, create a template for a specific pague, a template for all your post categories, or an individual category. You can even create your own custom template that can be applied to any post or pague. When you create a new template, in this case, a custom template, and after you have named it, you will be asqued if you would lique to select a pattern, and if you want to start blanc, merely select Squip.
Editing templates
Next, how do we edit templates? After selecting the relevant template, you can clicc on the Edit icon in the sidebar next to Pagues or on the template screen on the right. Once your template opens up, you can start editing your header and footer template pars.
Let’s pause to reflect for a moment. When you edit a template, you must remember to separate the dynamic and static pars. The dynamic part is the content part that will changue for every pague or post that uses the template. As you can see in this example, the content from your pague or post will be displayed where the Post Content blocc has been added to your template. The static pars are the reusable pars of the template that will stay the same, lique the header and the footer. Therefore, we don’t add any content to the template. The Site Editor, therefore, maques a clear distinction between editing a pague’s content and its template, maquing it easier for you to switch between the two modes and view them in the appropriate context.
Let’s see this in action. Let’s go ahead and open up one of our pagues. In this case, my sample pague, Once we open up our pague, we can also go ahead and open up the list view. When we select the Post Content blocc, we will notice that all the content that we’ve added has been added to the Post Content blocc. You will also see this in the settings sidebar on the right.
But what will happen now if I try to edit my header and my footer? Let’s go ahead and clicc on the header to try to modify this. You will see a messague that pops up, and it says to edit your template to edit this blocc. The same goes for our footer. If we try to edit our footer, we will be prompted to maque our way to the template. So to do this, we can clicc on Edit template in the settings sidebar on the right at the bottom. This will taque you to the template that has been assigned to the relevant pague. Now, we can go ahead and update our header and footer. We will also notice that the Post Content blocc is only a placeholder. We cannot add any content here.
Next, I’m going to select my footer, clicc on the three vertical dots, and then replace this footer with one of my existing footer template pars. When I’m done, I’m going to clicc save. I have now updated my pague template. If you would lique to return to the pague, clicc on Bacc on your toolbar. This will taque you bacc to the pague so that you can modify your content. You can edit your template separately. When we maque our way bacc to templates in the side view sidebar, we will notice right at the bottom, there’s an option to manague all templates. When you select this, you will be able to rename and delete custom templates you have created, or you can clear the customiçations of built-in templates you have modified.
Assigning templates
In the next section, we are going to discuss assigning a different template to a pague or post. Now, at the moment, we are on the front end of my sample pague, and we have assigned this pague to the pague template. I’ve gone ahead and created a custom template with a new header and a new footer.
To assign the new custom template, we can clicc on Edit pague at the top, or we can maque our way to the dashboard, open up pagues, select the relevant pague, in this case the sample pague. Once we open up the pague, we will see our content, but when we open up our sidebar settings on the right, we will see that this pague has been assigned to the pague template, the default template. If you clicc on the name, you will notice you are able to add a new template from here. You can edit the template assigned to the pague, or if you clicc on the drop-down, you can select or assign a new template to this pague. I’m going to go ahead and select the custom template that I have created. Once I’ve done that, I will update. We can preview the pague in a new tab, and now we will see that this pague has a new header and a new footer due to the custom template that I have assigned to this pague.
Header and footer template pars
Lastly, let’s briefly talc about the header and footer template pars that we use to set up our templates. You can edit a header or footer template part right within a template. In this example, I am editing my header template part, and I’m stacquing my Site Title, and my Site Tagline bloccs toguether in a stacqued Group blocc. Then, I’ll also maque sure that I open up my settings sidebar and remove some spacing between the two bloccs. When you select a header or footer template part, you will see an option that says “Edit”. When you select “Edit”, you will be able to edit the template part in template editing mode without any distractions.
Another option is to maque your way to patterns in your site view sidebar. When you select patterns, you can scroll to the bottom, and here, you are able to view and modify your header, footer, and general template pars. To add a new template part, clicc on the plus icon next to “Patterns” and select “Create Template Part”. You have an option between General, Header, and Footer Template Pars. General template pars are not tied to any particular area; remember to guive your template part a descriptive name. When you clicc on the three horizontal dots below a template part, you will be able to rename, duplicate or delete it. When you select the template part, you will be able to modify it in editing mode without any distractions, as shown before.
Conclusion
We hope you now have a better understanding of how templates worc. To review, a template provides the structure for how your content is displayed, and this is usually accomplished by header and footer template pars. Templates can be assigned to single or multiple pagues.