#title next/head not working for SEO

17 messages · Page 1 of 1 (latest)

warm heart
#

i've got a page title that i've placed inside a Head tag brought in from next/head, but when i curl my URL the page title isn't returned like the meta description tag is. the title does show if i import Head from next/document.

is there something that i'm missing, or is this a potential bug with Head from next/head?

Edit: i am not using the app directory

slender wolfBOT
#

🔎 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)
earnest epoch
warm heart
#

I’m not using app directory, updated op to include that info

warm heart
#

below is an example of one title that is working and that isn't in my usecase. let me know if there's any other info i can provide.```
import { Html, Head } from 'next/document'
import NextHead from 'next/head'

export default class Document {
render() {
return (
<Html lang="en">
{/* this page title does return in curl */}
<Head>
<title>Page Title 1</title>
</Head>

            {/* this page title does not return in curl */}
            <NextHead>
                <title>Page Title 2</title>
            </NextHead>
        </Html>
    )
}

}

rocky hollow
warm heart
#

what i've been noticing is that while the page loads, Page Title 1 renders, but once the page has finished loading, it then shows Page Title 2

rocky hollow
#

In the first place you’re only supposed to use <Head /> in the document file, to customise the head you do it in pages and in _app and in other components

warm heart
#

technically, things are actually working as expected from a usecase scenario. it's really these docs that are throwing me off

rocky hollow
#

_document.js is a sacred place, put your logic inside other components

warm heart
#

understood-- then is there something i'm missing with next/head that i'd need to do to get <title> tags to return in curl commands?

rocky hollow
#

Ensure it is rendered in all branches of your code (so not something like if (loading) return null)

warm heart
#

i can't believe i didn't think of this... thank you so much!