# Add Social Cards to an Eleventy Blog

Yes. An agent renders a card image per post at build time with the image plugin the site already has, adds the Open Graph tags that point at it, and builds the site.

[Run this on Rush](https://cloud.getrush.ai/run/add-social-cards/eleventy/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads what a shared link shows today and what the build already has to draw with. In a blog like 11ty/eleventy-base-blog, `_includes/layouts/base.njk` puts a `<title>`, a `description` meta tag and the Atom feed link in `<head>` and nothing for Open Graph or Twitter, so a link pasted into Slack or Mastodon shows text and no image. `package-lock.json` resolves `@11ty/eleventy` to 3.1.8 and `@11ty/eleventy-img` to 7.1.1 with `sharp` 0.35.5 underneath it, and `eleventy.config.js` already registers `eleventyImageTransformPlugin` for the images inside posts. Every post under `content/blog/` carries `title`, `description`, `date` and `tags` in its front matter, `content/blog/blog.11tydata.js` puts them all in the `posts` collection, and `_data/metadata.js` holds the site title, URL and author. `content/sitemap.xml.njk` shows how an absolute URL is built here: `page.url | htmlBaseUrl(metadata.url)`, a filter from the `HtmlBasePlugin` the config already adds.

It draws the cards with what is installed instead of adding a renderer. The image plugin accepts a Buffer as input, and `sharp` rasterises SVG, so the agent writes a small module, `_config/social-card.js`, that builds an SVG string for a post, the site title at the top, the post title wrapped onto a few lines, the date and the author at the bottom, and passes it to `Image()` from `@11ty/eleventy-img` with `formats: ["png"]`, one width, `outputDir: "./_site/og/"` and `urlPath: "/og/"`. The plugin caches by content hash, so a post whose title has not changed is not re-rendered on the next build. Line wrapping is done by the module on word boundaries, because SVG text does not wrap by itself, and the font is named in the SVG as a family the build host has; the agent renders one card in its sandbox, saves it as an artifact of the run so the reviewer can look at it, and notes that a different host may substitute the font.

The cards are produced by an async shortcode, `{% ogImage %}`, registered in `eleventy.config.js` beside the existing `currentBuildDate` shortcode, which returns the card's URL for the current page; a post layout calls it once. The tags go into `base.njk`: `og:title` from `title or metadata.title`, `og:description` from the same fallback the description meta already uses, `og:url` from `page.url | htmlBaseUrl(metadata.url)`, `og:type` of `article` on posts and `website` elsewhere, `og:image` with the card's absolute URL, and `twitter:card` set to `summary_large_image`. Pages that are not posts get a single site-wide card rendered from the site title, so the home page and the tag pages share a link preview too.

There is no test suite in this repository, so the proof is the build. The agent runs `npx @11ty/eleventy`, the `build` script, checks that `_site/og/` holds one PNG per post plus the site card, and reads `_site/blog/firstpost/index.html` to confirm the six meta tags and that the `og:image` URL begins with the site URL from `metadata.js`, which the reviewer must change from `https://example.com/` if they have not already. It runs the `--pathprefix` build from the `build-ghpages` script as well, because the HTML base plugin must prefix the card URL when the site deploys under a subdirectory.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add social card images to this Eleventy blog. Read package.json and the lockfile, eleventy.config.js, _data/metadata.js, the layouts under _includes, the post front matter under content/blog and content/sitemap.xml.njk first. Use the image plugin and sharp already installed: write a module that builds an SVG card for a post (site title, wrapped post title, date, author), renders it to PNG with Image() from @11ty/eleventy-img into _site/og/, and expose it as an async shortcode in eleventy.config.js. Add og:title, og:description, og:url, og:type, og:image and twitter:card to the base layout, building absolute URLs with the htmlBaseUrl filter the sitemap uses, with a site-wide card for pages that are not posts. Render one card in your environment and attach it to the run so a reviewer can see it; say which font the SVG names. Run the build script and the pathprefix build, confirm _site/og/ has one PNG per post and that a built post page carries the tags, paste the output in the pull request and open it.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that adds `_config/social-card.js`, registers one shortcode in `eleventy.config.js`, and changes `_includes/layouts/base.njk` and `post.njk`; no new dependency, since the image plugin and `sharp` were already in the lockfile. The description quotes the build output with the count of files written to `_site/og/`, the `<head>` of one built post, and a link to the sample card the run produced as an artifact of the session.

A reviewer looks at the card before the code: whether the font rendered as intended on the build host, whether a long title wraps without clipping, and whether the colours match the site. Then they check `og:url` on a page built with a path prefix, and set the real site URL in `_data/metadata.js` if the placeholder is still there, because every absolute URL in the tags comes from it.

They also check the cache: the image plugin writes by content hash, so renaming a post changes its card URL and the old PNG stays in `_site/og/` until a clean build, which the pull request mentions.

## Run it on every Linear issue labelled design

Changes to the card's look come as issues. In the console, add an automation on the Project that holds the repository with a `linear` trigger on `linear.issue.labeled` and the label `design`, and a prompt that says: change the social card template in _config/social-card.js as the issue describes, render one card and attach it to the run, run the build, and open a pull request. The issue is placed after the prompt as the event and fills in nothing, so the colours, fonts or layout come from the issue text. The trigger needs a Linear connection for the automation's runner and fires only when the label is applied by someone in your Rush org.

## Why run it on Rush?

A social card is judged by looking at it, and a build-time renderer is judged by what it does on a machine that is not yours: which fonts exist, whether `sharp` rasterises the SVG the way the local preview did, how long the build takes with one PNG per post. The agent runs the build in its own sandbox and hands back the rendered card as a file, so the reviewer sees the same output a deploy would produce rather than a screenshot from a laptop with different fonts.

The build output and the read-back of the built HTML stay in the run's transcript at `GET /o/{org}/sessions/{id}/messages`, the sample card is listed under the session's artifacts with a download link, and the changed files are listed with their diff at `GET /o/{org}/p/{project}/sessions/{id}/changes`.

## Frequently asked questions

### Does this add a dependency like Satori or Puppeteer?

No. The lockfile already has `@11ty/eleventy-img` and `sharp`, and `sharp` renders SVG to PNG. The card is an SVG string the agent builds from the post's front matter and passes to the image plugin, which writes the PNG and caches it by content hash.

### Why does the font matter?

SVG text is drawn with a font installed on the machine that runs the build, not one shipped with the site. The agent names a widely available family in the SVG, renders a sample in its sandbox and attaches it, and the reviewer checks the deploy host renders it the same way; a host without the font substitutes another.

### Will every build re-render every card?

No. The image plugin names output by a hash of its input and skips files that already exist, so only posts whose title, date or author changed are re-rendered. A post renamed or deleted leaves its old PNG in the output directory until a clean build.

### What about pages that are not posts?

They share one site-wide card rendered from the site title and description in `_data/metadata.js`, and `og:type` is `website` on them. Posts get `article` and their own image.

## More Eleventy jobs

- [Add JSON-LD Structured Data to an Eleventy Blog](https://getrush.ai/run/add-structured-data/eleventy/)
- [Add a Table of Contents to Eleventy Blog Posts](https://getrush.ai/run/add-table-of-contents/eleventy/)
- [Add a Typo Check to an Eleventy Blog in CI](https://getrush.ai/run/add-typo-check/eleventy/)

## The same job on other stacks

- [Add Social Card Images to a Gatsby Blog](https://getrush.ai/run/add-social-cards/gatsby/)
- [Add Social Cards to a Hugo Site](https://getrush.ai/run/add-social-cards/hugo/)
- [Add Social Preview Cards to a MkDocs Material Site](https://getrush.ai/run/add-social-cards/mkdocs/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
