Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,130 --> 00:00:05,080
Now with all our pages finished
2
00:00:05,080 --> 00:00:08,140
and with all that data being fetched and used,
3
00:00:08,140 --> 00:00:11,730
and with us being able to add a new meetup here,
4
00:00:11,730 --> 00:00:14,690
with that we added all the functionality
5
00:00:14,690 --> 00:00:17,980
that I wanted to add to this demo project
6
00:00:17,980 --> 00:00:22,980
and with that, we also used all those core NextJS features:
7
00:00:23,594 --> 00:00:27,430
file-based routing, API routes
8
00:00:27,430 --> 00:00:30,060
and of course, also page pre-rendering
9
00:00:30,060 --> 00:00:33,323
with data fetching, for example, with getStaticProps.
10
00:00:34,480 --> 00:00:38,240
Now that this app is finished, what's missing?
11
00:00:38,240 --> 00:00:40,210
Well, we wanna deploy it.
12
00:00:40,210 --> 00:00:43,410
We don't just wanna have it here locally
13
00:00:43,410 --> 00:00:47,020
on our local machine with that development server
14
00:00:47,020 --> 00:00:49,080
but instead, we wanna deploy it,
15
00:00:49,080 --> 00:00:51,330
put it onto a remote machine
16
00:00:51,330 --> 00:00:54,080
so that users from all over the world
17
00:00:54,080 --> 00:00:56,550
can visit our application.
18
00:00:56,550 --> 00:00:59,840
Now, therefore, we are going to deploy it
19
00:00:59,840 --> 00:01:02,160
but before we do that,
20
00:01:02,160 --> 00:01:04,620
there is one thing we should also do,
21
00:01:04,620 --> 00:01:07,150
one thing you should double check
22
00:01:07,150 --> 00:01:10,460
for any kind of NextJS project you're building
23
00:01:10,460 --> 00:01:13,930
or for any kind of web project in general.
24
00:01:13,930 --> 00:01:15,560
And that's metadata,
25
00:01:15,560 --> 00:01:18,780
which you might wanna add to your pages.
26
00:01:18,780 --> 00:01:21,590
The content is there on our pages.
27
00:01:21,590 --> 00:01:25,070
We do have the content visible on the screen
28
00:01:25,070 --> 00:01:27,830
and that's the most important part, of course.
29
00:01:27,830 --> 00:01:32,410
But at this point, we haven't added any metadata.
30
00:01:32,410 --> 00:01:35,366
If we inspect the rendered HTML code,
31
00:01:35,366 --> 00:01:39,460
the head section is relatively empty.
32
00:01:39,460 --> 00:01:41,810
We do have some meta tags here
33
00:01:41,810 --> 00:01:44,880
but we are missing the description meta tag,
34
00:01:44,880 --> 00:01:47,930
which would be important for search engines.
35
00:01:47,930 --> 00:01:50,720
I'm talking about the description meta tag,
36
00:01:50,720 --> 00:01:52,970
which allows you to set descriptions,
37
00:01:52,970 --> 00:01:56,833
which, for example, show up on a Google search here.
38
00:01:58,270 --> 00:02:00,630
And we're also missing a page title,
39
00:02:00,630 --> 00:02:03,500
which is why here in the tab title,
40
00:02:03,500 --> 00:02:06,720
we only see the address as a title.
41
00:02:06,720 --> 00:02:08,740
And if our pages would show up
42
00:02:08,740 --> 00:02:10,889
as search results later,
43
00:02:10,889 --> 00:02:13,790
we also want the title like in this case here,
44
00:02:13,790 --> 00:02:16,310
Academind, for my own website.
45
00:02:16,310 --> 00:02:18,380
So setting such meta tags,
46
00:02:18,380 --> 00:02:20,640
adding such Head elements,
47
00:02:20,640 --> 00:02:23,430
that is something we definitely also wanna do
48
00:02:23,430 --> 00:02:24,630
when we build a site
49
00:02:24,630 --> 00:02:28,030
and that is something which we wanna do here as well.
50
00:02:28,030 --> 00:02:31,880
And adding such head elements to our pages
51
00:02:31,880 --> 00:02:35,496
is thankfully very simple with NextJS.
52
00:02:35,496 --> 00:02:38,300
Let's start on the index.js page.
53
00:02:38,300 --> 00:02:40,400
So the HomePage.
54
00:02:40,400 --> 00:02:43,610
There we definitely wanna set some title
55
00:02:43,610 --> 00:02:47,460
and we definitely also wanna add a description.
56
00:02:47,460 --> 00:02:52,460
And to do that, we can import a special component offered
57
00:02:52,610 --> 00:02:57,610
by NextJS, the Head component imported from next/head.
58
00:02:59,500 --> 00:03:03,610
This is a component which allows you to add Head elements
59
00:03:03,610 --> 00:03:06,960
to the Head section of your page.
60
00:03:06,960 --> 00:03:08,400
How do you use it?
61
00:03:08,400 --> 00:03:12,290
You simply add it to your returned JSX code.
62
00:03:12,290 --> 00:03:14,270
So here next to the MeetupList,
63
00:03:14,270 --> 00:03:18,820
I wanna add the Head element, the Head component
64
00:03:18,820 --> 00:03:22,150
and since adjacent JSX code is not allowed,
65
00:03:22,150 --> 00:03:25,410
I will use the React Fragment imported
66
00:03:25,410 --> 00:03:29,350
from React, here is the import,
67
00:03:29,350 --> 00:03:31,400
imported from React.
68
00:03:31,400 --> 00:03:35,473
I'll use Fragment to wrap Head and MeetupList.
69
00:03:36,740 --> 00:03:40,520
And now inside of these Head tags here
70
00:03:40,520 --> 00:03:44,300
between the opening and closing Head component tag,
71
00:03:44,300 --> 00:03:48,230
there you can now insert your Head elements.
72
00:03:48,230 --> 00:03:50,240
So all the HTML elements,
73
00:03:50,240 --> 00:03:52,230
which you can add in the Head section,
74
00:03:52,230 --> 00:03:53,370
you can add them here.
75
00:03:53,370 --> 00:03:55,660
Like for example, the title.
76
00:03:55,660 --> 00:03:57,650
And then we could give this page a title
77
00:03:57,650 --> 00:04:02,650
of React Meetups, or whatever title we want to have here.
78
00:04:03,050 --> 00:04:06,980
And actually make sure that this is returned like this.
79
00:04:06,980 --> 00:04:08,780
If we then save this,
80
00:04:08,780 --> 00:04:11,760
and we visit our starting page,
81
00:04:11,760 --> 00:04:14,060
you will notice that now here
82
00:04:14,060 --> 00:04:19,060
in the tab title, we see that title which I set here.
83
00:04:19,320 --> 00:04:22,800
And of course, we also see this in the page source code.
84
00:04:22,800 --> 00:04:25,010
There we'll be able to find the title
85
00:04:25,010 --> 00:04:26,233
in the Head section.
86
00:04:27,320 --> 00:04:28,253
Here it is.
87
00:04:29,410 --> 00:04:31,770
And we also see that if we open the dev tools
88
00:04:31,770 --> 00:04:33,920
and inspect the rendered elements here.
89
00:04:33,920 --> 00:04:35,703
Here's our title as well.
90
00:04:37,360 --> 00:04:39,580
So that's how we can add a title
91
00:04:39,580 --> 00:04:43,140
and that's how we can also add this meta tag,
92
00:04:43,140 --> 00:04:44,680
which holds the description,
93
00:04:44,680 --> 00:04:49,560
which will be picked up by search engines, like Google.
94
00:04:49,560 --> 00:04:54,560
Browse a huge list of highly active React meetups.
95
00:04:55,910 --> 00:04:59,890
That could be our meta description for this page
96
00:04:59,890 --> 00:05:01,220
and that would be the text
97
00:05:01,220 --> 00:05:04,320
which shows up when our page shows up
98
00:05:04,320 --> 00:05:07,973
as a result on a search engine, for example.
99
00:05:08,840 --> 00:05:11,890
So with that added, we now added some meta data,
100
00:05:11,890 --> 00:05:14,660
some Head data to this starting page.
101
00:05:14,660 --> 00:05:17,100
And we can do this on all the pages.
102
00:05:17,100 --> 00:05:19,810
On the NewMeetupPage, for example,
103
00:05:19,810 --> 00:05:22,810
I don't just wanna return the NewMeetupForm,
104
00:05:22,810 --> 00:05:25,790
but also add the Fragment here imported
105
00:05:25,790 --> 00:05:27,313
from React of course,
106
00:05:28,570 --> 00:05:31,820
and then between the Fragment opening and closing tags,
107
00:05:31,820 --> 00:05:36,680
have our adjacent JSX code to have the Head section there
108
00:05:36,680 --> 00:05:38,400
and the NewMeetupForm.
109
00:05:38,400 --> 00:05:39,940
Head is, of course, a component
110
00:05:39,940 --> 00:05:41,779
which we also need to import now.
111
00:05:41,779 --> 00:05:46,533
So import Head from next/head like this.
112
00:05:48,080 --> 00:05:50,920
And now here we can set a title as well,
113
00:05:50,920 --> 00:05:54,170
like Add a New Meetup.
114
00:05:54,170 --> 00:05:55,820
And we can also update the description
115
00:05:55,820 --> 00:06:00,130
and change this to Add your own meetups.
116
00:06:00,130 --> 00:06:05,093
Create amazing networking opportunities.
117
00:06:06,460 --> 00:06:07,293
Like this.
118
00:06:08,490 --> 00:06:10,520
So now this is added here as well
119
00:06:11,550 --> 00:06:15,110
and hence, if we visit the Add New Meetup page,
120
00:06:15,110 --> 00:06:17,040
we see our title here
121
00:06:17,040 --> 00:06:18,610
and of course, in the dev tools,
122
00:06:18,610 --> 00:06:22,530
we also see this description meta tag here
123
00:06:22,530 --> 00:06:23,743
in the Head section.
124
00:06:25,620 --> 00:06:26,730
Now, last but not least,
125
00:06:26,730 --> 00:06:28,540
we also want to set a title
126
00:06:28,540 --> 00:06:32,810
and show a description if we view a single meetup.
127
00:06:32,810 --> 00:06:34,130
And therefore, we should also go
128
00:06:34,130 --> 00:06:36,570
to this single meetupId page
129
00:06:36,570 --> 00:06:39,630
and also wrap this into a Fragment here
130
00:06:41,090 --> 00:06:44,410
and add this Head component
131
00:06:44,410 --> 00:06:48,063
and bring the MeetupDetail into this Fragment as well.
132
00:06:48,990 --> 00:06:51,840
And then, of course, make sure that you import Fragment
133
00:06:51,840 --> 00:06:56,840
from React and import Head from next/head, like this.
134
00:06:58,250 --> 00:07:01,630
And then here between the opening and closing Head tags,
135
00:07:01,630 --> 00:07:03,150
we can also add a title
136
00:07:03,150 --> 00:07:04,850
and of course, here the title
137
00:07:04,850 --> 00:07:07,890
will not be a static hard coded title
138
00:07:07,890 --> 00:07:09,740
as it on the other pages
139
00:07:09,740 --> 00:07:12,300
where it's always the same title
140
00:07:12,300 --> 00:07:15,660
but instead here, for a single loaded meetup item
141
00:07:15,660 --> 00:07:17,420
on that MeetupDetails page,
142
00:07:17,420 --> 00:07:21,960
here I actually want to use the title of that meetup
143
00:07:21,960 --> 00:07:24,054
as a title for this page
144
00:07:24,054 --> 00:07:26,040
so that different meetups
145
00:07:26,040 --> 00:07:28,173
have different titles on their pages.
146
00:07:29,230 --> 00:07:32,480
And hence different meetups showing up on a search engine,
147
00:07:32,480 --> 00:07:35,270
which show up with different titles
148
00:07:35,270 --> 00:07:37,760
and descriptions there as well.
149
00:07:37,760 --> 00:07:40,790
And making this title dynamic instead of static
150
00:07:40,790 --> 00:07:42,280
is super simple.
151
00:07:42,280 --> 00:07:45,570
After all, we are in our regular returned
152
00:07:45,570 --> 00:07:48,190
JSX code snippet block.
153
00:07:48,190 --> 00:07:51,650
So we can use all the standard React features here
154
00:07:51,650 --> 00:07:53,830
and for example, output the result
155
00:07:53,830 --> 00:07:57,390
of a dynamic expression with curly braces.
156
00:07:57,390 --> 00:08:02,370
And then output props.meetupData.title as a title here
157
00:08:02,370 --> 00:08:05,380
and then add this meta tag here
158
00:08:05,380 --> 00:08:08,500
for the description, oops, description.
159
00:08:08,500 --> 00:08:11,603
And a content of some content.
160
00:08:12,860 --> 00:08:15,200
And then here make the content dynamic
161
00:08:15,200 --> 00:08:20,200
and output props.meetupData.description, for example,
162
00:08:21,440 --> 00:08:24,653
or whatever you wanna output as a description.
163
00:08:25,520 --> 00:08:29,320
And therefore, we can set a hard coded description
164
00:08:29,320 --> 00:08:33,230
as we do it on the Add a New Meetup page, for example.
165
00:08:33,230 --> 00:08:35,909
But we can also set a dynamic value
166
00:08:35,909 --> 00:08:37,293
as we're doing it here.
167
00:08:38,239 --> 00:08:41,840
And with that, if we save this and reload this page,
168
00:08:41,840 --> 00:08:44,370
this single meetup page,
169
00:08:44,370 --> 00:08:47,230
we see that title here in the tab
170
00:08:47,230 --> 00:08:49,067
and if we inspect this here,
171
00:08:49,067 --> 00:08:51,900
in the Head section, we also see the title
172
00:08:51,900 --> 00:08:53,540
and we see this description
173
00:08:53,540 --> 00:08:56,233
with the actual meetup description text.
174
00:08:57,220 --> 00:09:00,920
And now with that, we really prepared our page
175
00:09:00,920 --> 00:09:04,170
for deployment, our website for deployment
176
00:09:04,170 --> 00:09:06,060
because with that, we make sure
177
00:09:06,060 --> 00:09:09,350
that search engines get all that extra metadata
178
00:09:09,350 --> 00:09:14,100
and we also show our users some nice titles here as well.
179
00:09:14,100 --> 00:09:17,163
And with that, let's now deploy this site.
13798
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.