Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

490
Vistas
How to set og:image in Nuxt.js Nuxt/Content blog with images in content folders

How do I get a string representation of a deployed image's final location that I can supply to the og:image header code and have the og:header point to the correct url when deployed?

I have a website that is based on Nuxt.js and Nuxt Content. To keep things organized, I have modified the usual nuxt set up so that I can bundle post .md files and the images they reference into a single folder, rather than keeping all images in a separate /static or /assets folder. The site is deployed on netlify in static/generate mode.

When I share a post, I want services like reddit to select an appropriate thumbnail image, so I want to configure og:image headers on each post.

Github code here. The posts are in /content/posts, and I use the v-img component in the markdown files to show images in that post's folder.

I've figured out how to add og:image headers this in the slug file for posts:

  head () {
    return {
      title: this.post.title,
      meta: [
        {
          hid: 'description',
          name: 'description',
          content: this.post.description
        },
        {
          hid: 'og:image',
          property: 'og:image',
          content: 'https://brianssparetime.com/_nuxt/content' + this.post.dir + '/' + this.post.image
        }
      ]
    }
  }

However, when the blog is deployed, this does not work because the deployed image link changes. For example, in dev mode, this.post.image might point to pos_DSC01447.jpg, but in the deployed site, the image has been moved to pos_DSC01447.37e98b4.jpg where that additional bit changes with each deploy. In the deployed version, this.post.image lacks this additional bit, leading to incorrect urls for og:image.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Solved but davydnorris in this github issue comment. Answer is content: 'https://www.brianssparetime.com' + require(\@/content${this.post.dir}/${this.post.image}`)`

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda