# Add Open Graph and Twitter Card Tags to an Eleventy Blog

Yes. An agent adds Open Graph and Twitter card meta tags to your Eleventy blog's base layout, filled from each post's front matter, and opens a PR.

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

## What the agent does

The agent starts with the layout chain. In a blog like 11ty/eleventy-base-blog, every page renders through `_includes/layouts/base.njk`, whose `<head>` carries a `<title>` of `{{ title or metadata.title }}`, one `description` meta tag with the same fallback, and the Atom feed link; there is no `og:` or `twitter:` tag anywhere. Posts use `_includes/layouts/post.njk`, which declares `layout: layouts/base.njk` in its front matter, so a post's `title`, `description` and `date` already reach the base layout. Site-wide values live in `_data/metadata.js`: `title`, `url` (still `https://example.com/`), `language`, `description` and an `author` object. `eleventy.config.js` registers `HtmlBasePlugin`, and `content/sitemap.xml.njk` already turns a relative `page.url` into an absolute one with `page.url | htmlBaseUrl(metadata.url)`, which is the same filter the share tags need.

It then adds one block to the base layout's `<head>`. `og:site_name` and `og:locale` come from `metadata.title` and `metadata.language`; `og:title` and `og:description` reuse the fallbacks the `<title>` tag already uses; `og:url` is `page.url | htmlBaseUrl(metadata.url)`. `og:type` is `article` when the page's `tags` include `posts`, which `content/blog/blog.11tydata.js` adds to every post, and `website` otherwise, and an article also gets `article:published_time` from `page.date | htmlDateString`, the filter `_config/filters.js` defines for the sitemap. The `twitter:card` tag is `summary_large_image` when an image is set and `summary` when none is.

Images need an absolute URL that the `eleventy-img` transform does not rewrite, because that plugin only processes image elements in the body, such as the `./possum.png` in `content/blog/fourthpost/fourthpost.md`. So the agent adds an optional `image` front matter key, documented in `content/blog/firstpost.md` as an example, and a default share image path in `_data/metadata.js`; a file under `public/img/` reaches the site root through the `addPassthroughCopy({"./public/": "/"})` line in `eleventy.config.js`. It extends `_data/eleventyDataSchema.js`, where a Zod schema already validates the `draft` key, with `image: z.optional(z.string())`, so a typo in the key fails the build the same way an invalid `draft` does.

The proof is the built HTML. The agent runs `npm install` and `npm run build`, which is `npx @11ty/eleventy` on the Node 22 that `.nvmrc` pins, then reads `_site/index.html`, `_site/blog/firstpost/index.html` and `_site/about/index.html` to show the tags on a home page, a post and a plain page, and that `og:url` is absolute. It leaves `metadata.url` as it found it and says in the pull request that the share tags are only right once that value is the real domain, the same caveat the sitemap already carries.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add Open Graph and Twitter card meta tags to this Eleventy site. Read eleventy.config.js, _data/metadata.js, _data/eleventyDataSchema.js, _includes/layouts/base.njk, _includes/layouts/post.njk, content/blog/blog.11tydata.js and two posts first. In the base layout add og:site_name, og:locale, og:title, og:description, og:url (absolute, through the htmlBaseUrl filter with metadata.url), og:type (article for pages tagged posts, website otherwise), article:published_time for articles, og:image and twitter:card, with twitter:card falling back to summary when there is no image. Support an optional image front matter key with a site-wide default in metadata.js, validate the key in eleventyDataSchema.js, add one example to a post, and keep every existing head tag. Run npm install and npm run build, show the tags in the built HTML for the home page, one post and the about page, and open a pull request that notes metadata.url must be set to the real domain.",
  "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

What comes back is a pull request on its own branch touching `_includes/layouts/base.njk` (the new meta block), `_data/metadata.js` (a default share image path), `_data/eleventyDataSchema.js` (the `image` rule), one post's front matter as the example, a share image under `public/img/`, and a short README note on the `image` key. `eleventy.config.js`, the post layout and the other posts are unchanged.

The description quotes the rendered `<head>` of a post and of the home page from `_site`, so a reviewer sees `og:type` switch between `article` and `website` and sees the absolute `og:url` without building anything. The build output is in the transcript at `GET /o/{org}/sessions/{id}/messages` beside the command that produced it.

Before merging, a reviewer sets `url` in `_data/metadata.js` if it is still the placeholder, opens one built page in a card validator, and decides whether the default image is the one they want. A follow-up message to the same session can add `og:image:alt` or an `article:author` tag from `metadata.author`.

## Run it on every Linear issue labelled seo

A team that tracks site work in Linear starts one run per issue from an automation with a `linear` trigger on the `seo` label. The automation adds the issue after this prompt, so an issue that asks for a particular default image or for `article:author` as well is what the agent reads, and the run starts in the repository the automation names.

Each run opens its own pull request from its own sandbox, and an automation run has its own `max_runs_per_hour` cap. The pull request links the issue and quotes the built HTML, so the review is a read of one layout file and one rendered page.

## Why run it on Rush?

Share tags are a small change that is easy to get subtly wrong: a relative `og:url`, a `twitter:card` that names an image the page does not have, a key that posts spell three ways. The agent reads the real layout chain and the real filters, builds the site with the repository's own `npm run build`, and checks the output HTML rather than trusting the template, in a sandbox with the pinned Node and the lockfile's packages.

The pull request carries the built `<head>` for three kinds of page in its description and the full build log in the transcript. Several sites can be handled at once, each in its own sandbox, each with one pull request.

## Frequently asked questions

### Does this change how my posts are written?

Only by adding an optional `image` key. Posts without it keep working and fall back to the site-wide default in `_data/metadata.js`; `title`, `description` and `date` are read from the front matter the posts already have.

### Why not use the eleventy-img plugin for og:image?

The transform plugin in `eleventy.config.js` rewrites image elements in the page body and writes hashed files, which is right for inline images but gives a meta tag nothing to point at. A plain path under `public/`, copied to the site root by the existing passthrough rule, gives a stable absolute URL. The pull request notes how to generate a sized image with the plugin's shortcode later if the team wants one per post.

### What if metadata.url is still example.com?

The tags render with that domain, exactly as `content/sitemap.xml.njk` already does. The agent does not guess the real domain; it says in the pull request that `url` in `_data/metadata.js` must be set, and the reviewer sets it once for both.

### Will the build fail on a bad image key?

Yes, on purpose. `_data/eleventyDataSchema.js` already runs a Zod schema over every page's data and throws on an invalid `draft`; the agent adds `image` to that schema so a number or a list in the key stops the build with a readable error instead of producing an empty tag.

## More Eleventy jobs

- [Add Pagination to an Eleventy Blog Archive](https://getrush.ai/run/add-pagination/eleventy/)
- [Add Reading Time to an Eleventy Blog](https://getrush.ai/run/add-reading-time/eleventy/)
- [Add Related Posts by Shared Tags to an Eleventy Blog](https://getrush.ai/run/add-related-posts/eleventy/)

## The same job on other stacks

- [Add Open Graph and Twitter Card Tags to a Jekyll Blog on GitHub Pages](https://getrush.ai/run/add-open-graph-tags/jekyll/)
- [Add Open Graph Tags to a Leptos App](https://getrush.ai/run/add-open-graph-tags/leptos/)
- [Add Open Graph Tags to an mdBook Site](https://getrush.ai/run/add-open-graph-tags/mdbook/)

## 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/)
