All jobs

Add Open Graph Tags to a Leptos App

Yes. An agent adds Open Graph and Twitter card tags to your Leptos app with leptos_meta, rendered on the server per route, checks the HTML, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads how the head is already built. In an app generated from leptos-rs/start-axum, Cargo.toml depends on leptos, leptos_router and leptos_meta at 0.8 with leptos_meta/ssr in the ssr feature, and src/app.rs has a shell function whose <head> holds the charset and viewport tags, AutoReload, HydrationScripts and <MetaTags/>, the component that writes everything the meta components produce into the server-rendered head. App calls provide_meta_context(), sets <Stylesheet id="leptos" href="/pkg/{{project-name}}.css"/> and <Title text="Welcome to Leptos"/>, and routes a single StaticSegment("") to HomePage. src/main.rs serves it with axum through leptos_routes and file_and_error_handler(shell). There is no <Meta> of any kind, no description, and public/ holds only favicon.ico, so a link shared to the app shows a bare URL.

It also reads what cargo-leptos will copy and test. [package.metadata.leptos] sets assets-dir to public, so a file placed there lands in target/site beside pkg/, site-addr to 127.0.0.1:3000, and end2end-cmd to npx playwright test in end2end/, where tests/example.spec.ts asserts the page title is Welcome to Leptos and the h1 reads Welcome to Leptos!. The rust-toolchain.toml pins nightly, Cargo.lock is ignored by .gitignore, and there is no CI workflow, so the end-to-end run is the only check that exists.

The change lives in src/app.rs. In App, next to the existing Title, the agent adds site-wide <Meta name="description" .../>, <Meta property="og:type" content="website"/>, <Meta property="og:site_name" .../>, <Meta property="og:image" .../> and <Meta name="twitter:card" content="summary_large_image"/>, using the property and name props leptos_meta::Meta takes. In HomePage it adds og:title, og:description and og:url for that route, so a page component overrides the site defaults and a new route only has to add its own three tags. The origin for og:url and the image comes from one SITE_ORIGIN constant at the top of app.rs with a comment, because get_configuration reads only the leptos metadata and nothing in the repository knows the public host yet. A 1200 by 630 PNG goes to public/og-image.png, which assets-dir copies to the site root.

In its sandbox the agent installs the nightly toolchain, the wasm32-unknown-unknown target and cargo-leptos, replaces the {{project-name}} placeholders the template leaves behind so the crate compiles, and runs cargo leptos build. It starts the server binary from target/server/debug, fetches / with curl and greps the response for every property="og: and name="twitter: tag to prove they are in the server-rendered HTML rather than added by the WebAssembly bundle after load. It extends end2end/tests/example.spec.ts with an assertion on the og:title content, runs cargo leptos end-to-end, and keeps the HTML and the Playwright report.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add Open Graph and Twitter card meta tags to this Leptos app. Read Cargo.toml, src/app.rs, src/main.rs, src/lib.rs, public/, style/main.scss and end2end/tests/example.spec.ts first. Using leptos_meta's Meta component, add site-wide description, og:type, og:site_name, og:image and twitter:card tags beside the existing Title in App, and per-route og:title, og:description and og:url tags in each page component, starting with HomePage. Put the public origin in one named constant with a comment, since nothing in the repository holds it, and add a 1200 by 630 og-image.png under the assets directory cargo-leptos copies. Build with cargo leptos, start the server, fetch the home page with curl and show every new tag in the server-rendered HTML, then add a Playwright assertion on og:title to the end-to-end test and run it. Open a pull request that pastes the curl output and the test result. Do not add a crate for this and do not change the router or the stylesheet.",
  "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

The pull request changes src/app.rs, adds public/og-image.png, and extends end2end/tests/example.spec.ts. Its description pastes the <head> of the server-rendered home page as curl received it, with the MetaTags output showing the site-wide tags and the route's og:title, og:description and og:url, and the Playwright summary from cargo leptos end-to-end.

A short section names the SITE_ORIGIN constant and the two places it is used, so the reviewer sees the one line to change when the host is known, and explains that a page component's tags take effect only for that route because each Meta component is mounted with its page.

Before merging, a reviewer sets the real origin, decides whether the description text belongs in a config file or an environment variable read on the server, and checks the image against the brand, since the agent's PNG is a placeholder with the app name on it.

Run it on every new route in the app

In the console, an automation on the Project with a github trigger on pull_request.opened and pull_request.synchronize and the prompt "if this pull request adds a Route in src/app.rs, check that its page component sets og:title, og:description and og:url, add them if they are missing, build with cargo leptos, curl the new route and comment with the head tags" starts one run per pull request. The trigger adds the pull request after the prompt, so the agent reads the diff rather than a placeholder, and only work by an owner, member or collaborator fires it.

From your own server the same work is one POST /o/{org}/sessions per repository with the repository in resources, and a request_id that is a UUID v5 of the repository's full name so a retried call returns the run already started. A webhook_url on the key reports run.completed with the pull request in result, or run.failed for an app whose nightly build no longer compiles.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Meta tags for a crawler have to be in the HTML the server sends, not in what the WebAssembly bundle writes after it loads, and the only way to know is to build the app, start the binary and read the response. The agent's sandbox installs nightly Rust, the wasm target and cargo-leptos, runs the real build and keeps the curl output and the Playwright report with the run.

The change is small, but the choices in it come from this repository: MetaTags already in the shell, assets-dir for the image, the one route to start from and the absence of any host configuration. One run per app, each in its own sandbox, and a reviewer reads the head as a crawler would see it.

Frequently asked questions

Are the tags in the HTML a crawler receives?

Yes. shell renders <MetaTags/> inside <head>, and during server rendering leptos_meta injects the output of every Meta, Title and Link component there before the response is sent. The agent proves it with curl rather than a browser, since curl runs no WebAssembly.

Do per-page tags override the site-wide ones?

The site-wide tags live in App and apply everywhere; a page component adds og:title, og:description and og:url for its route. The agent keeps the two sets disjoint, so there is nothing to override and no duplicate property in the head, and says so in the description.

Where does the public URL come from?

Nothing in the template holds it: get_configuration reads only the [package.metadata.leptos] table, which has site-addr for binding and no public origin. The agent adds one SITE_ORIGIN constant in src/app.rs with a comment and uses it for og:url and og:image, so the reviewer changes one line.

Does it need another crate?

No. leptos_meta is already a dependency with its ssr feature wired into the ssr feature set, and its Meta component takes name, property and content. The pull request adds no dependency.

More Leptos jobs

The same job on other stacks

Keep reading