Go to file
Krzysztof Żuraw 359fd09c80
fix: update readme for free zeit accounts (#109)
* fix: update readme for free zeit accounts

* docs: fix wording in readme

Co-Authored-By: Steven <steven@ceriously.com>

Co-authored-by: Steven <steven@ceriously.com>
2020-04-14 14:51:21 -04:00
.github Add codeowners file 2019-03-13 16:33:27 -04:00
api Upgrade Node 10 to Node 12 (#106) 2020-04-06 13:58:11 -04:00
public Remove builds in favor of zero-config (#87) 2019-07-25 12:35:12 -04:00
web Change default to ZEIT logo, remove Now logo (#102) 2019-11-11 11:38:55 -05:00
.gitignore Upgrade Node 10 to Node 12 (#106) 2020-04-06 13:58:11 -04:00
.nowignore Remove builds in favor of zero-config (#87) 2019-07-25 12:35:12 -04:00
.yarnrc Move to zeit org (#67) 2019-03-04 13:34:38 -05:00
CONTRIBUTING.md Fix links to code in contributing.md (#92) 2019-07-25 15:21:57 -04:00
Dockerfile Add Dockerfile 2019-02-05 13:27:23 -08:00
LICENSE Create LICENSE 2019-01-29 17:18:30 -05:00
now.json Change routes to rewrites (#104) 2019-12-09 09:59:40 -05:00
package.json Upgrade Node 10 to Node 12 (#106) 2020-04-06 13:58:11 -04:00
README.md fix: update readme for free zeit accounts (#109) 2020-04-14 14:51:21 -04:00
yarn.lock Upgrade Node 10 to Node 12 (#106) 2020-04-06 13:58:11 -04:00

Open Graph Image as a Service

Serverless service that generates dynamic Open Graph images that you can embed in your <meta> tags.

For each keystroke, headless chromium is used to render an HTML page and take a screenshot of the result which gets cached.

See the image embedded in the tweet for a real use case.

What is an Open Graph Image?

Have you ever posted a hyperlink to Twitter, Facebook, or Slack and seen an image popup? How did your social network know how to "unfurl" the URL and get an image? The answer is in your <head>.

The Open Graph protocol says you can put a <meta> tag in the <head> of a webpage to define this image.

It looks like the following:

<head>
  <title>Title</title>
  <meta property="og:image" content="http://example.com/logo.jpg" />
</head>

Why use this service?

Read the blog post for more info on the "Why" part.

The short answer is that it would take a long time to painstakingly design an image for every single blog post. And we don't want the exact same image for every blog post because that wouldn't make the article stand out when it was shared to Twitter.

That's where og-image.now.sh comes in. We can simply pass the title of our blog post to our generator service and it will generate the image for us on the fly!

It looks like the following:

<head>
  <title>Hello World</title>
  <meta property="og:image" content="https://og-image.now.sh/Hello%20World.png" />
</head>

Now try changing the text Hello%20World to the title of your choosing and watch the magic happen

Deploy your own

You'll want to fork this repository and deploy your own image generator.

  1. Click the fork button at the top right of GitHub
  2. Clone the repo to your local machine with git clone URL_OF_FORKED_REPO_HERE
  3. Change directory with cd og-image
  4. Make changes by swapping out images, changing colors, etc (see contributing for more info)
  5. Run locally with now dev and visit localhost:3000 (if nothing happens, run npm install -g now)
  6. Deploy to the cloud by running now and you'll get a unique URL
  7. Setup GitHub to autodeploy on push

Alternatively, you can do a one-click to deploy with the button below.

Deploy to now

If you are using free ZEIT Now plan, you will need to remove all configuration inside now.json besides rewrites. So your now.json should look like this:

{
  "rewrites": [
    { "source": "/(.+)", "destination": "/api" }
  ]
}

Once you have an image generator that sparks joy, you can setup automatic Now + GitHub deployments so that pushing to master is also deploying to production! 🚀

Authors