Metas ok in Localhost but missing after generation

Hi! :slight_smile:

I have an issue with my meta data.

Here, my head function in my single page blog article:

head() {
      return {
        title: this.page.data.meta_title,
        meta: [
          { charset: "utf-8" },
          { name: "viewport", content: "width=device-width, initial-scale=1" },
          { name: "format-detection", content: "telephone=no" },
          {
            hid: "description",
            name: "description",
            content: this.page.data.meta_description,
          },
          { property: "og:type", content: "website" },
          { property: "og:title", content: this.page.data.meta_title },
          { property: "og:url", content: process.env.baseUrl + this.page.url },
          { property: "og:image", content: this.page.data.og_image.url },
          { property: "og:image:type", content: "image/jpg" },
          {
            property: "og:description",
            content: this.page.data.meta_description,
          },
        ],
      };
    },

In localhost, everything is working fine.

<title>French Tech Weeks</title>
<meta data-n-head="ssr" charset="utf-8">
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
<meta data-n-head="ssr" name="format-detection" content="telephone=no">
<meta data-n-head="ssr" charset="utf-8">
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
<meta data-n-head="ssr" name="format-detection" content="telephone=no">
<meta data-n-head="ssr" data-hid="description" name="description" content="French Tech Weeks">
<meta data-n-head="ssr" property="og:type" content="website">
<meta data-n-head="ssr" property="og:title" content="French Tech Weeks">
<meta data-n-head="ssr" property="og:url" content="http://localhost:3000/blog/tech/french-tech-weeks">
<meta data-n-head="ssr" property="og:image" content="https://images.prismic.io/publicom/45b1c7cc-a5d6-4d4c-95b2-6c16c26ae44d_french-tech-weeks.webp?auto=compress,format">
<meta data-n-head="ssr" property="og:image:type" content="image/jpg">
<meta data-n-head="ssr" property="og:description" content="French Tech Weeks">

But after my nuxt build (netlfify, static) , everything is gone :frowning:

<head>
<title>Publicom</title>
<meta data-n-head="1" charset="utf-8">
<meta data-n-head="1" name="viewport" content="width=device-width,initial-scale=1">
<meta data-n-head="1" data-hid="description" name="description" content="">
<meta data-n-head="1" name="format-detection" content="telephone=no">
<link data-n-head="1" rel="icon" type="image/x-icon" href="[/favicon.ico](https://dev.publicom.agency/favicon.ico)">
</head>

This model of meta is what i have in my nuxt.config.js file.

 // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'Publicom',
    htmlAttrs: {
      lang: 'fr'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

I use the prispic apiOptions route in this file :slight_smile:

prismic: {
    endpoint: apiEndpoint,
    modern: true,
    /* see configuration for more */
    apiOptions: {
      routes: [
        {
          type: 'article',
          path: '/blog/:category/:uid',
          resolvers: {
            category: 'category'
          }
        }
      ],
    },
  },

All blog articles are generated correctly, but without meta...

Any ideas?
Thanks a lot ! :heart:

Hi Vincent

Are you building statically? If so is the rest of your content generating statically in the view source?

Hi Jake!

Yes, it's a static site. All my content is generated statically in the view source.

Ok thanks,

Does the Netlify build log give any warnings/errors? I can't otherwise think why it wouldn't be working.

What if you generate it locally?

Hi @jake !

I have no error in my build log.

Locally, It seems that single blog pages are not generated...

image

Curious...

My nuxt.config.js file:

generate: {
    exclude: ['/slice-simulator'],
    crawler: true,
    fallback: true
  },

  prismic: {
    endpoint: apiEndpoint,
    modern: true,
    /* see configuration for more */
    apiOptions: {
      routes: [
        // Resolves the Homepage document to "/"
        {
          type: 'homepage',
          path: '/',
        },
        {
          type: 'article',
          path: '/blog/:category/:uid',
          resolvers: {
            category: 'category'
          }
        },
        {
          type: 'client',
          path: '/cas-clients/:uid'
        }
      ],
    },
  },

Hi Vincent

Ah ok! is this blog post being linked to anywhere in your site? Try adding it to your homepage (even just to test) and see if it statically generates.

Also if you're using a sitemap generator - check to see if it's being included in the list. :slight_smile:

1 Like

All blog posts are listed on the blog index page.
Isn't that enough for the generation?

(thanks for your help / time :wink: )

2 Likes

No problem at all :slight_smile:

When the generation happens, if it can't find a link to the page/article then it can't generate the content/meta information for it as it doesn't know it exists, that's why you either have to link everything up or set the routes.

Is the blog linked to anywhere on the main index page?

Another thing you try is adding the blog and/or article (article link for testing) to the nuxt config generate routes array:

generate: {
  routes: ['/blog', '/blog/article-name']
}

See if that works for generating/meta data correctly set.

Hopefully this helps us get to the bottom of it :smiley:

2 Likes