How to change the head title using metadata?
Unanswered
Arctic Tern posted this in #help-forum
Arctic TernOP
I’m using nextjs 13.1 and I want to change the head title of every page in my application using metadata that has been provided by the nextjs 13, but couldn’t find it
32 Replies
@Arctic Tern I’m using nextjs 13.1 and I want to change the head title of every page in my application using metadata that has been provided by the nextjs 13, but couldn’t find it
export const metadata = {
title: "Hello world"
}in your root layout?
Giant panda
13.1 doesn't have the metadata API IIRC
Arctic TernOP
where can I find root layout
couldn't find root layout in my application
Giant panda
Typically
/app/layout.tsxLiterally the layout file at the root of your project
Arctic TernOP
but there is no app/layout.tsx in my application, I have used roqAI to generate the nextjs app....
Giant panda
I have no clue what roqAI is. Any normally bootstraped Next app nowadays comes with a root layout. You'd have to share more details, what's your file structure etc.
@Giant panda 13.1 doesn't have the metadata API IIRC
oh yeah... well, upgrade to next latest then
13.4.13
Arctic TernOP
I used roqAI to generate the application, which can provide most of the code using nextjs + prisma
I can share the file structure too
oh so you don't use the app router. in that case use [next/head](https://nextjs.org/docs/pages/api-reference/components/head)
use it in any pages to set the title of that page
use it in _app to set the title of everything
Arctic TernOP
so https://www.roq.ai/ is providing page router only?
that one i don't know, i don't work for them and have never used it
Arctic TernOP
how can I tell that the nextjs application is using app router or page router ????
but pages router still works fine
@Arctic Tern how can I tell that the nextjs application is using app router or page router ????
presence of src/pages or pages directory
app router then it would be src/app or app
Arctic TernOP
so if I create app folder in the nextjs app, that means I can use app router ?
yes basically
but pages router still works fine and you don't have to migrate to the app router now if you are not ready yet – it will take a lot of effort
Arctic TernOP
I don't know if I have to use app router or not, I think I should stick with the page router that comes with the generated app
yup i would say that's a wise choice
nothing wrong with the pages router currently and it doesn't have bugs and issues like the app router has
Arctic TernOP
have you encountered any issue in app router by yourself?
I mean I really want to try it
Issues then there are lots of it, but at the same time it solves many design problems that the pages router fundamentally faces (that cannot be fixed in the pages router)
Just try it and see