#NextJS App router <base /> tag in head

10 messages · Page 1 of 1 (latest)

olive aspen
#

How would I add the base tag to the head tag when using app router?

autumn roostBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

ivory island
#

my thought was generateMetadata might allow putting custom tags on the head tag. but after some digging, it doesn't seem to be the case since it's hardcoded to only be able to put specific meta tags and nothing else

well, afaik it's not possible to do so, what are you trying to achieve with a base tag anyway? to be honest, this is the first time I've ever heard of it lol

patent pewter
#

You shouldn't be needing that base tag. You can directly use relative links and they will work as needed. If there is a specific use case you want then please mention it.

For metadata, there is metadataBase: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase

If you are deploying under a children directory for example /docs you can use basePath, it is automatically applied to links:
https://nextjs.org/docs/app/api-reference/next-config-js/basePath

Moreover you should be able to use the <head> tag inside the main layout file.

Use basePath to deploy a Next.js application under a sub-path of a domain.

Learn how to add Metadata to your Next.js application for improved search engine optimization (SEO) and web shareability.

olive aspen
patent pewter
olive aspen
#

My app takes input. And that is correct, propper sanitization would mitigate that. That does not fix my issue however, since having the base tag to pass the certificates requirement is what I need to solve

#

When testing it seems like I can´t use the head-tag at the same time as exporting the metaData object? Correct?

#

So If I want to add the base tag I should resort to a traditional head-tag with meta tags etc inside?

lean dove
#

you can add a head tag inside the root layout(s) normally. it works in conjunction with the metadata object system very well.