Sources: video-subtitle-pipeline artifacts/beginner-wordpress-user/ - subtitles/: en, zh, bilingual SRT/ASS (100 files) - platform/: youtube SRT + bilibili BCC per video (75 files) - manifests/: per-video manifest.json (25 files) - quality/: quality reports (50 files)
447 lines
11 KiB
Text
447 lines
11 KiB
Text
1
|
|
00:00:00,000 --> 00:00:04,000
|
|
In this lesson, we will delve deeper into templates.
|
|
|
|
2
|
|
00:00:06,000 --> 00:00:10,988
|
|
At the end of this tutorial, we want to be able to differentiate between pages and templates,
|
|
|
|
3
|
|
00:00:10,988 --> 00:00:16,429
|
|
know how to modify one of our base templates, how to add a new template,
|
|
|
|
4
|
|
00:00:16,429 --> 00:00:21,417
|
|
and lastly, how to assign a custom template to a page or post.
|
|
|
|
5
|
|
00:00:21,417 --> 00:00:26,000
|
|
A template provides the structure for how a page is displayed.
|
|
|
|
6
|
|
00:00:26,000 --> 00:00:36,000
|
|
That usually includes a header template part, a content area, and a footer template part.
|
|
|
|
7
|
|
00:00:38,000 --> 00:00:42,000
|
|
I think it is important to clarify the following information from the start.
|
|
|
|
8
|
|
00:00:42,000 --> 00:00:44,378
|
|
Templates are not for posting content,
|
|
|
|
9
|
|
00:00:44,378 --> 00:00:50,000
|
|
and templates for a post or page display your content with the post content block.
|
|
|
|
10
|
|
00:00:50,000 --> 00:00:53,267
|
|
Templates are, as the name implies, design templates
|
|
|
|
11
|
|
00:00:53,267 --> 00:00:57,000
|
|
that can be applied to single or multiple pages and posts.
|
|
|
|
12
|
|
00:00:58,000 --> 00:01:02,000
|
|
To access templates, make your way to Appearance and click on Editor.
|
|
|
|
13
|
|
00:01:02,000 --> 00:01:05,000
|
|
This will take you to your site editor.
|
|
|
|
14
|
|
00:01:06,000 --> 00:01:19,186
|
|
The editor can be used to customize the styles of your entire site, edit pages, modify templates,
|
|
|
|
15
|
|
00:01:19,186 --> 00:01:27,000
|
|
as well as manage all the different patterns on your site.
|
|
|
|
16
|
|
00:01:30,000 --> 00:01:35,720
|
|
When you start building a new website, you can edit existing templates or add new ones,
|
|
|
|
17
|
|
00:01:35,720 --> 00:01:41,000
|
|
and the theme you are using will determine which existing or built-in templates are available to use.
|
|
|
|
18
|
|
00:01:41,000 --> 00:01:49,000
|
|
So first up is the page template, which creates the structure for how individual pages will be displayed.
|
|
|
|
19
|
|
00:01:51,000 --> 00:01:59,000
|
|
Next is the single post template, which displays a single blog post.
|
|
|
|
20
|
|
00:02:03,000 --> 00:02:13,000
|
|
The index template displays posts, and the 404 template displays when no content is found.
|
|
|
|
21
|
|
00:02:14,000 --> 00:02:18,000
|
|
And these templates can of course all be modified as you please.
|
|
|
|
22
|
|
00:02:19,000 --> 00:02:23,000
|
|
Then there are also other built-in templates worth exploring.
|
|
|
|
23
|
|
00:02:23,000 --> 00:02:25,000
|
|
For example, a blank template.
|
|
|
|
24
|
|
00:02:28,000 --> 00:02:33,000
|
|
To add a new template, click on the Insertor or Plus icon next to templates.
|
|
|
|
25
|
|
00:02:33,000 --> 00:02:37,000
|
|
A modal appears where you can choose between different template options.
|
|
|
|
26
|
|
00:02:37,000 --> 00:02:40,857
|
|
You can, for example, create a template for a specific page,
|
|
|
|
27
|
|
00:02:40,857 --> 00:02:46,000
|
|
or a template for all your post categories, or an individual category.
|
|
|
|
28
|
|
00:02:46,000 --> 00:02:51,000
|
|
You can even create your own custom template that can be applied to any post or page.
|
|
|
|
29
|
|
00:02:53,000 --> 00:03:00,492
|
|
When you create a new template, in this case a custom template, and after you have named it,
|
|
|
|
30
|
|
00:03:00,492 --> 00:03:10,000
|
|
you will be asked if you would like to select a pattern, and if you want to start blank, merely select Skip.
|
|
|
|
31
|
|
00:03:11,000 --> 00:03:14,000
|
|
Next, how do we edit templates?
|
|
|
|
32
|
|
00:03:14,000 --> 00:03:20,810
|
|
After selecting the relevant template, you can click on the Edit icon in the sidebar next to Pages,
|
|
|
|
33
|
|
00:03:20,810 --> 00:03:25,000
|
|
or on the Template screen on the right.
|
|
|
|
34
|
|
00:03:26,000 --> 00:03:31,000
|
|
Once your template opens up, you can start editing your header and footer template parts.
|
|
|
|
35
|
|
00:03:31,000 --> 00:03:34,000
|
|
Let's pause to reflect for a moment.
|
|
|
|
36
|
|
00:03:34,000 --> 00:03:40,000
|
|
When you edit a template, you need to remember to separate the dynamic parts and the static parts.
|
|
|
|
37
|
|
00:03:40,000 --> 00:03:46,000
|
|
The dynamic part is the content part that will change for every page or post that uses the template.
|
|
|
|
38
|
|
00:03:46,000 --> 00:03:51,600
|
|
And as you can see in this example, the content from your page or post will be displayed
|
|
|
|
39
|
|
00:03:51,600 --> 00:03:55,000
|
|
where the post content block has been added in your template.
|
|
|
|
40
|
|
00:03:55,000 --> 00:03:59,500
|
|
The static parts are the reusable parts of the template that will stay the same,
|
|
|
|
41
|
|
00:03:59,500 --> 00:04:01,000
|
|
like the header and the footer.
|
|
|
|
42
|
|
00:04:01,000 --> 00:04:05,000
|
|
We therefore don't add any content to the template.
|
|
|
|
43
|
|
00:04:06,000 --> 00:04:11,571
|
|
The site editor therefore makes a clear distinction between editing a page's content and its template,
|
|
|
|
44
|
|
00:04:11,571 --> 00:04:18,000
|
|
making it easier for you to switch between the two modes and view them in the appropriate context.
|
|
|
|
45
|
|
00:04:18,000 --> 00:04:21,000
|
|
Let's see this in action.
|
|
|
|
46
|
|
00:04:21,000 --> 00:04:25,000
|
|
So let's go ahead and open up one of our pages.
|
|
|
|
47
|
|
00:04:25,000 --> 00:04:29,000
|
|
And in this case, my sample page.
|
|
|
|
48
|
|
00:04:29,000 --> 00:04:34,000
|
|
Once we open up our page, we can also go ahead and open up the list view.
|
|
|
|
49
|
|
00:04:35,000 --> 00:04:41,000
|
|
And when we select the post content block, we will notice that all our content that we've added
|
|
|
|
50
|
|
00:04:41,000 --> 00:04:44,000
|
|
has been added to the post content block.
|
|
|
|
51
|
|
00:04:44,000 --> 00:04:49,000
|
|
You will also see this in the settings sidebar on the right.
|
|
|
|
52
|
|
00:04:49,000 --> 00:04:54,000
|
|
But what will happen now if I try to edit my header and my footer?
|
|
|
|
53
|
|
00:04:54,000 --> 00:04:59,000
|
|
Let's go ahead and click on the header to try and modify this.
|
|
|
|
54
|
|
00:04:59,000 --> 00:05:04,000
|
|
You will see a message that pops up and it says edit your template to edit this block.
|
|
|
|
55
|
|
00:05:04,000 --> 00:05:08,000
|
|
And the same goes for our footer.
|
|
|
|
56
|
|
00:05:08,000 --> 00:05:16,000
|
|
If we try and edit our footer, we will be prompted to make our way to the template.
|
|
|
|
57
|
|
00:05:16,000 --> 00:05:25,000
|
|
So to do this, we can click on edit template in the settings sidebar on the right at the bottom.
|
|
|
|
58
|
|
00:05:25,000 --> 00:05:29,000
|
|
This will take you to the template that has been assigned to the relevant page.
|
|
|
|
59
|
|
00:05:29,000 --> 00:05:34,000
|
|
And now we can go ahead and update our header and our footer.
|
|
|
|
60
|
|
00:05:34,000 --> 00:05:39,000
|
|
And we will notice that the post content block is only a placeholder.
|
|
|
|
61
|
|
00:05:39,000 --> 00:05:43,000
|
|
We cannot add any content here.
|
|
|
|
62
|
|
00:05:43,000 --> 00:05:50,156
|
|
Next, I'm going to select my footer, click on the three vertical dots,
|
|
|
|
63
|
|
00:05:50,156 --> 00:05:57,000
|
|
and then replace this footer with one of my existing footer template parts.
|
|
|
|
64
|
|
00:05:57,000 --> 00:06:00,385
|
|
And when I'm done, I'm going to click save.
|
|
|
|
65
|
|
00:06:00,385 --> 00:06:05,000
|
|
And now I have updated my page template.
|
|
|
|
66
|
|
00:06:05,000 --> 00:06:11,000
|
|
If you would like to return to the page, click on back on your toolbar.
|
|
|
|
67
|
|
00:06:11,000 --> 00:06:15,000
|
|
And this will take you back to the page so that you can modify your content.
|
|
|
|
68
|
|
00:06:15,000 --> 00:06:19,000
|
|
And of course, you can edit your template separately.
|
|
|
|
69
|
|
00:06:19,000 --> 00:06:23,714
|
|
When we make our way back to templates in the side view sidebar,
|
|
|
|
70
|
|
00:06:23,714 --> 00:06:30,000
|
|
we will notice right at the bottom, there's an option to manage all templates.
|
|
|
|
71
|
|
00:06:30,000 --> 00:06:38,000
|
|
And when you select this, you'll be able to rename and delete custom templates you have created.
|
|
|
|
72
|
|
00:06:38,000 --> 00:06:46,000
|
|
Or you can clear the customizations of building templates you have modified.
|
|
|
|
73
|
|
00:06:46,000 --> 00:06:51,062
|
|
In the next section, we are going to discuss assigning a different template to a page or post.
|
|
|
|
74
|
|
00:06:51,062 --> 00:06:54,810
|
|
Now, at the moment, we are on the front end of my sample page,
|
|
|
|
75
|
|
00:06:54,810 --> 00:06:59,000
|
|
and we have assigned this page to the page template.
|
|
|
|
76
|
|
00:06:59,000 --> 00:07:05,000
|
|
I've gone ahead and created a custom template with a new header and a new footer.
|
|
|
|
77
|
|
00:07:05,000 --> 00:07:10,645
|
|
To assign the new custom template, we can click on edit page at the top,
|
|
|
|
78
|
|
00:07:10,645 --> 00:07:19,000
|
|
or we can make our way to the dashboard, open up pages, select the relevant page, in this case, the sample page.
|
|
|
|
79
|
|
00:07:19,000 --> 00:07:23,475
|
|
And then once we open up the page, we will see our content,
|
|
|
|
80
|
|
00:07:23,475 --> 00:07:31,000
|
|
but when we open up our sidebar settings, on the right, we will see that this page has been assigned to the page template, the default template.
|
|
|
|
81
|
|
00:07:31,000 --> 00:07:34,214
|
|
If you click on the name,
|
|
|
|
82
|
|
00:07:34,214 --> 00:07:40,000
|
|
you will notice you are able to add a new template from here.
|
|
|
|
83
|
|
00:07:40,000 --> 00:07:43,000
|
|
You can edit the template assigned to the page.
|
|
|
|
84
|
|
00:07:43,000 --> 00:07:50,000
|
|
Or if you click on the dropdown, you can select or assign a new template to this page.
|
|
|
|
85
|
|
00:07:50,000 --> 00:07:56,000
|
|
I'm going to go ahead and select the custom template which I have created.
|
|
|
|
86
|
|
00:07:56,000 --> 00:08:01,000
|
|
And once I've done that, I will update.
|
|
|
|
87
|
|
00:08:01,000 --> 00:08:05,800
|
|
We can preview the page in a new tab,
|
|
|
|
88
|
|
00:08:05,800 --> 00:08:17,000
|
|
and now we will see that this page has a new header and a new footer due to the custom template which I have assigned to this page.
|
|
|
|
89
|
|
00:08:17,000 --> 00:08:24,000
|
|
Lastly, let's briefly talk about header and footer template parts which we use to set up our templates.
|
|
|
|
90
|
|
00:08:24,000 --> 00:08:29,000
|
|
You can edit a header or footer template part right within a template.
|
|
|
|
91
|
|
00:08:29,000 --> 00:08:33,565
|
|
In this example, I am editing my header template part,
|
|
|
|
92
|
|
00:08:33,565 --> 00:08:39,000
|
|
and I'm stacking my site title and my site tagline block together in a stacked group block.
|
|
|
|
93
|
|
00:08:39,000 --> 00:08:45,182
|
|
Then I'll also make sure that I open up my settings sidebar,
|
|
|
|
94
|
|
00:08:45,182 --> 00:08:51,000
|
|
and I will remove some spacing between the two blocks.
|
|
|
|
95
|
|
00:08:51,000 --> 00:08:56,000
|
|
When you select a header or footer template part, you will see an option that says edit.
|
|
|
|
96
|
|
00:08:56,000 --> 00:09:06,000
|
|
When you select edit, you will be able to edit the template part in template editing mode without any distractions.
|
|
|
|
97
|
|
00:09:06,000 --> 00:09:14,000
|
|
Another option is to make your way to patterns in your site view sidebar.
|
|
|
|
98
|
|
00:09:14,000 --> 00:09:17,810
|
|
When you select patterns, you can scroll to the bottom,
|
|
|
|
99
|
|
00:09:17,810 --> 00:09:24,000
|
|
and here you are able to view and modify your header, footer and general template parts.
|
|
|
|
100
|
|
00:09:24,000 --> 00:09:28,735
|
|
To add a new template part, click on the plus icon next to patterns
|
|
|
|
101
|
|
00:09:28,735 --> 00:09:31,000
|
|
and select create template part.
|
|
|
|
102
|
|
00:09:31,000 --> 00:09:35,000
|
|
You have an option between general, header and footer template parts.
|
|
|
|
103
|
|
00:09:35,000 --> 00:09:38,579
|
|
General template parts are not tied to any particular area,
|
|
|
|
104
|
|
00:09:38,579 --> 00:09:43,000
|
|
and remember to give your template part a descriptive name.
|
|
|
|
105
|
|
00:09:43,000 --> 00:09:46,912
|
|
When you click on the three horizontal dots below a template part,
|
|
|
|
106
|
|
00:09:46,912 --> 00:09:50,000
|
|
you will be able to rename, duplicate or delete it.
|
|
|
|
107
|
|
00:09:50,000 --> 00:09:53,143
|
|
And when you select the template part,
|
|
|
|
108
|
|
00:09:53,143 --> 00:10:00,000
|
|
you will be able to modify it in editing mode without any distractions as shown before.
|
|
|
|
109
|
|
00:10:00,000 --> 00:10:03,000
|
|
We hope you now have a better understanding of how templates work.
|
|
|
|
110
|
|
00:10:03,000 --> 00:10:07,846
|
|
To review, a template provides the structure for how your content is displayed,
|
|
|
|
111
|
|
00:10:07,846 --> 00:10:12,000
|
|
and this is usually accomplished by header and footer template parts.
|
|
|
|
112
|
|
00:10:12,000 --> 00:10:16,000
|
|
And templates can be assigned to single or multiple pages.
|