Comments (1)
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:
- Import Helmet to the
service.js
template (templates/service.js
) like so:import Helmet from 'react-helmet';
- 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>
- 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-serif-theme.