1
00:00:00,000 --> 00:00:02,000
So you can set metadata

2
00:00:02,000 --> 00:00:04,000
in your NextJS applications

3
00:00:04,000 --> 00:00:07,000
by either setting static metadata

4
00:00:07,000 --> 00:00:09,000
with help of the metadata constant

5
00:00:09,000 --> 00:00:11,000
or variable that's exported,

6
00:00:11,000 --> 00:00:14,000
or by dynamically setting metadata

7
00:00:14,000 --> 00:00:17,000
with help of the generateMetadata function

8
00:00:17,000 --> 00:00:20,000
that's exported by your page.js file.

9
00:00:21,000 --> 00:00:26,000
You cannot just set metadata in page.js files though,

10
00:00:26,000 --> 00:00:29,000
instead you can also set it in the layout.js files.

11
00:00:29,000 --> 00:00:33,000
And indeed, there you should already have a metadata object

12
00:00:33,000 --> 00:00:36,000
that's being exported in the root layout here

13
00:00:36,000 --> 00:00:38,000
in that project I provided to you.

14
00:00:40,000 --> 00:00:44,000
And the idea behind setting up metadata in layouts

15
00:00:44,000 --> 00:00:48,000
is that this metadata will now be used for all the pages

16
00:00:48,000 --> 00:00:51,000
that don't set their own metadata,

17
00:00:51,000 --> 00:00:53,000
or to be precise,

18
00:00:53,000 --> 00:00:57,000
the metadata you set up in your layout will be merged

19
00:00:57,000 --> 00:01:00,000
with any metadata set up by a page.

20
00:01:00,000 --> 00:01:03,000
And if a page doesn't set up any metadata at all,

21
00:01:03,000 --> 00:01:06,000
it's this entire metadata object that will be used

22
00:01:06,000 --> 00:01:08,000
for this specific page.

23
00:01:08,000 --> 00:01:10,000
But if you had a page that just sets a title

24
00:01:10,000 --> 00:01:12,000
and not a description,

25
00:01:12,000 --> 00:01:16,000
the page title would override the layout metadata title,

26
00:01:16,000 --> 00:01:19,000
but the layout metadata description would be merged

27
00:01:19,000 --> 00:01:22,000
with the page specific title.

28
00:01:22,000 --> 00:01:25,000
And therefore setting up metadata in layouts

29
00:01:25,000 --> 00:01:27,000
can be useful for ensuring

30
00:01:27,000 --> 00:01:31,000
that there is at least some metadata in all your pages,

31
00:01:31,000 --> 00:01:33,000
but you can then still override it

32
00:01:33,000 --> 00:01:36,000
from inside some of your specific pages.

