Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

495
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!