GithubHelp home page GithubHelp logo

Comments (1)

elijah-io avatar elijah-io commented on May 20, 2024

Sorry, I think I might just be an idiot lol.

So, Helmet already enables this, I think I was just confused by the syntax at first.

So, I added a unique og:image to my homepage by adding this to my index.js file:

<meta property="og:image" content="/example-image.png"/>

This was added underneath the <meta name="description" content="..." part within <Helmet></Helmet> of the index.js file (around line 14 from this repo).

To add a dynamic og:image on the individual service pages, for example:

  1. Import Helmet to the service.js template (templates/service.js) like so: import Helmet from 'react-helmet';
  2. Create a Helmet like so, below the <Layout bodyClass="page-service"> opening around line 12:
<Helmet>
        <meta property="og:image" content={ image }/>
        <meta property="og:image:width" content="1200"/>
        <meta property="og:image:height" content="630"/>
</Helmet>
  1. Don't forget to include it in your graphql query (just add "image" underneath title or path).

This takes advantage of the specified images already in the individual service .md files.

It's important to include the og:image:width and :height because of some issue with Facebook not being able to render it otherwise. I went kinda quick and forgot/can't find the exact error message it gave me, but the specified width/height fixes it.

from gatsby-serif-theme.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.