So you can set metadata
in your NextJS applications
by either setting static metadata
with help of the metadata constant
or variable that's exported,
or by dynamically setting metadata
with help of the generateMetadata function
that's exported by your page.js file.
You cannot just set metadata in page.js files though,
instead you can also set it in the layout.js files.
And indeed, there you should already have a metadata object
that's being exported in the root layout here
in that project I provided to you.
And the idea behind setting up metadata in layouts
is that this metadata will now be used for all the pages
that don't set their own metadata,
or to be precise,
the metadata you set up in your layout will be merged
with any metadata set up by a page.
And if a page doesn't set up any metadata at all,
it's this entire metadata object that will be used
for this specific page.
But if you had a page that just sets a title
and not a description,
the page title would override the layout metadata title,
but the layout metadata description would be merged
with the page specific title.
And therefore setting up metadata in layouts
can be useful for ensuring
that there is at least some metadata in all your pages,
but you can then still override it
from inside some of your specific pages.