Connect with your AI agent
Paste one prompt into your coding agent. It adds your blog to your website, in your design, with the SEO set up, and tests it. Any framework, any host.
Copy, paste, done
Signed in? Your dashboard's “Connect your website” page has this prompt with your website's details already filled in. Your API key stays out of it.
Either way, the design is yours: your pages, header, footer, fonts and colours. Our HTML comes unstyled, so you (or your agent) style it to match your site.
- 1. Open your website's code in Claude Code, Codex, Cursor, Copilot or any coding agent.
- 2. Paste the prompt. The agent builds it, checks it the way AI crawlers see it, and tells you what's left.
- 3. Finish with the short dashboard checklist it gives you: about 2 minutes.
See the full prompt
Connect my website to Blogs for SEO the simple way, in this repository.
Docs (open them if you can; the guide is also copied in full below):
- Guide: https://blogsforseo.com/docs/connect/simple
- Content API reference: https://blogsforseo.com/docs/api
- Framework guides (Next.js, React Router, Astro, Nuxt, SvelteKit, Laravel, Django, Rails): https://blogsforseo.com/docs/connect/examples
My values:
- Blog sitemap: a separate file on my domain, `/blog-sitemap.xml`, never on Blogs for SEO's. Serve `GET {API}/sitemap?format=xml` there (fetched with the API key on the server, on each request like the blog pages). Never change the root `/sitemap.xml` or any existing sitemap. Add this line to robots.txt, keeping any Sitemap lines already there: `Sitemap: https://<my domain>/blog-sitemap.xml`
- API key: the one secret. Never ask me to paste it to you and never hardcode it. Read it on the server from the env var `BLOGSFORSEO_API_KEY` and send it with every API request as `Authorization: Bearer <key>`. Never send it to the browser. Tell me exactly where to add it: the project's local env file (e.g. `.env.local`), plus my host's or CI's secret settings for production. I'll copy it from the "Connect your website" page of my dashboard.
- Post URL pattern: not set yet. Use `/blog/{slug}` on my domain, unless the site already has a blog path, and tell me the full pattern.
- IndexNow key: ask me for it (it's on the "Connect your website" page of my dashboard). Don't skip this step.
- Required, don't skip: `/blog-sitemap.xml`, `/llms.txt` (serve `GET {API}/llms.txt` there) and the IndexNow key file. Search engines and AI assistants find new posts through them. If one can't be done, stop and tell me why.
How to work:
1. Look at the stack first: language and framework (any server language works: Node, Python, PHP, Ruby, Go…), how pages render, hosting, and the existing layout and styles. Tell me your plan in 5 lines or fewer, then build it.
2. The blog pages and the blog sitemap MUST fetch from the Blogs for SEO API on the server on every visit, so new posts appear within 5 minutes with no rebuild and no webhook. Hard rule: NOTHING may keep the API's answer for more than 5 minutes: no page cache, fetch cache, data cache or CDN rule longer than 300 seconds. For example: in Next.js put `{ next: { revalidate: 300 } }` on every Blogs for SEO fetch (or `export const revalidate = 300` on each blog route, the sitemap route included), and never use `cache: 'force-cache'`, or `unstable_cache` / `'use cache'` with a longer lifetime; in Django no `cache_page` or cache middleware over 300 seconds; in Laravel no `Cache::remember` or response cache over 300 seconds; in Rails no `Rails.cache` or `expires_in` over 5 minutes. Search the code for every Blogs for SEO fetch and check each one. If this site is built once ahead of time (Next.js `output: 'export'`, Gatsby, Hugo, Jekyll, Eleventy, Astro without a server, or plain file hosting), that requirement isn't met: switch the blog pages to render on each request (in Next.js remove `output: 'export'` and use `export const revalidate = 300`; elsewhere turn on server rendering with the host's adapter). Never fetch posts in the browser instead: AI crawlers don't run JavaScript. If this needs a hosting change (e.g. running a Node server instead of serving files), explain exactly what changes and ask me before you make it.
3. If this site can't be edited as code (e.g. hosted WordPress, Webflow, Shopify, Wix), stop and tell me. Point me to https://blogsforseo.com/services.
4. Show our HTML inside the site's own layout (header, footer, page width). Then write CSS for the `bfs-` classes so the blog matches the site's fonts, colours and spacing. Use the starter stylesheet only if the site has no styles to match.
5. Ask me before anything outside this repository: deploying, DNS, or paying for anything.
6. Check with curl, pretending to be GPTBot (`curl -A GPTBot`): the blog page lists posts or shows "No posts yet"; a post page's raw HTML has the `<h1>`, article text, canonical link and `application/ld+json`; a made-up slug returns 404; robots.txt has the `Sitemap:` line; `/llms.txt` returns the API's llms.txt as plain text; the IndexNow key file returns just the key; and the blog routes are rendered per request, not saved as files at build time (e.g. the Next.js build output doesn't mark them static). Freshness check: the number of posts on `/blog` equals `total` from the API, and `/blog-sitemap.xml` lists the same posts as `GET {API}/sitemap`. Then run the project's lint, typecheck and tests.
7. Finish with: the files you changed, and the guide's "Finish in the dashboard" steps filled in with my real URLs.
---
# Guide: connect the simple way
The simple way: we send finished HTML for your blog, with the SEO already done. Your site puts it inside its own pages. You need two pages, one sitemap, one line in robots.txt and one small text file.
**You still own the design.** Our HTML has no styles, fonts or scripts. It takes on your site's own look, inside your own header and footer. Every part has a `bfs-` class name (`bfs-title`, `bfs-short-answer`, `bfs-faqs` and so on) for anything you want to restyle. For a starting point, add our optional [starter stylesheet](https://blogsforseo.com/blogsforseo.css) and change what you like.
**Using a coding agent?** Copy the prompt from your dashboard's "Connect your website" page. It has your keys filled in.
**Using Next.js, React Router, Astro, Nuxt, SvelteKit, Laravel, Django or Rails?** The [framework guides](/docs/connect/examples) do every step below, ready to paste.
## Before you start: your blog must stay fresh
Your blog pages, and your blog sitemap, must ask our API for posts on your server, on every visit. A cache of **at most 5 minutes** is fine. That's how new posts, edits and removals reach your site with no rebuild and nothing else to set up.
**The one rule for caching: nothing may keep our API's answer for more than 5 minutes.** That covers every cache your stack has: page caches, fetch caches, data caches and your CDN. For example:
- **Next.js:** on every blogsforseo fetch use `{ next: { revalidate: 300 } }` (or `cache: 'no-store'`), or `export const revalidate = 300` on each blog route, the sitemap route included. Never `cache: 'force-cache'`, and never `unstable_cache` or `'use cache'` without a lifetime of 300 seconds or less.
- **Django, Laravel, Rails and others:** the same rule for their caches (`cache_page`, `Cache::remember`, `Rails.cache`), `Cache-Control` headers and any CDN rules on `/blog` and `/blog-sitemap.xml`.
**Is your site built once, ahead of time?** That covers static exports (Next.js `output: 'export'`), Gatsby, Hugo, Jekyll, Eleventy, and Astro without a server. A site like that saves each page as a file at deploy time, and never asks our API again, so new posts never appear. Switch your blog pages to render on each request:
- **Next.js:** remove `output: 'export'` and render the blog pages on each request, cached for at most 5 minutes (e.g. `export const revalidate = 300`). The rest of the site can stay static.
- **Astro, Nuxt, SvelteKit, Remix:** turn on server rendering for the blog pages, with your host's adapter.
- **Your host:** this needs somewhere that runs server code: Vercel, Netlify, Cloudflare, a Node server, or similar. Plain file hosting (S3, GitHub Pages) can't do it.
Never fetch posts in the visitor's browser instead: AI crawlers don't run JavaScript, so they'd see an empty blog. In frameworks that also run in the browser (Nuxt, Next.js client components), fetch through your own server route, so the key never leaves your server. Their hydration data will repeat the post body; that's expected.
## What you need
Three things from your dashboard's "Connect your website" page:
- **API key:** the one secret. It also tells us which website you are. Put it in your server's environment as `BLOGSFORSEO_API_KEY`: in `.env` locally, and in your host's (or GitHub's) secret settings for production. Never put it in your code or send it to the browser. In JavaScript frameworks, read it at runtime on the server, never at build time: a key read during the build is copied into the build output. For example, in Nuxt leave `runtimeConfig`'s value empty and set `NUXT_BLOGSFORSEO_API_KEY` when the server starts; writing `process.env.BLOGSFORSEO_API_KEY` into `runtimeConfig` bakes the key into `.output`.
- **Sitemap line:** the robots.txt line for your blog sitemap (step 3). Not secret.
- **IndexNow key:** 32 characters for step 4. Not secret.
Send the API key with every request, as a header: `Authorization: Bearer <your API key>`. Without it, the API answers 401.
In this guide, `{API}` means `https://blogsforseo.com/api/v1`.
## 1. Blog page
Make a page for your blog, e.g. `/blog`. On your server, fetch:
```
GET {API}/html/posts?page=1
Authorization: Bearer <your API key>
```
You get `{ body, page, totalPages, total }`. Put `body` in your page. Pass your page's own `?page=` number through, so the Newer and Older links work: use it when it's a whole number from 1, otherwise use 1 (the API answers 400 for things like `abc` or `0`).
## 2. Post page
Make a page for posts, e.g. `/blog/{slug}`. On your server, fetch:
```
GET {API}/html/posts/{slug}
Authorization: Bearer <your API key>
```
You get `{ head, body, meta }`:
- Only ask the API for slugs that look like ours (`^[a-z0-9-]+$`: lowercase letters, digits and hyphens). Answer anything else with a 404 straight away.
- Put `head` inside your page's `<head>`: the title, description, canonical link and social tags. Most frameworks can print it as HTML (Astro, SvelteKit, Django, Laravel, Rails). Only where the framework builds `<head>` from values (Next.js, Nuxt), use `meta` instead: it holds the same values ([its fields](/docs/api)).
- Put `body` in your page. It is the whole article, structured data included.
- If we answer 404, your page must answer 404 too.
Do both pages on the server, on every visit (see "Before you start"), never in the browser.
## 3. Blog sitemap on your site
Your blog gets its own sitemap file on your own domain, `/blog-sitemap.xml`. Never ours, and never your main `/sitemap.xml`: leave that as it is. On your server, on every visit like the blog pages, serve this at `/blog-sitemap.xml`:
```
GET {API}/sitemap?format=xml
Authorization: Bearer <your API key>
```
Then add the sitemap line from your dashboard to your robots.txt, next to any Sitemap lines already there:
```
Sitemap: https://example.com/blog-sitemap.xml
```
This tells Google and Bing where your posts are. If your robots.txt blocks the crawlers AI answers cite from, such as OAI-SearchBot, Claude-SearchBot or PerplexityBot, remove those blocks too. Blocking GPTBot or ClaudeBot only affects AI training, not citations, so that's your choice.
## 4. IndexNow key file
Serve a plain-text file at `/{INDEXNOW_KEY}.txt` on your site, containing just the key. On every publish we tell Bing, which ChatGPT search and Copilot also use, so new posts are found within minutes instead of days.
## 5. llms.txt
Serve `GET {API}/llms.txt` (plain text, with the API key, on the server) at your site's `/llms.txt`. AI assistants read it as a map of your posts. If your site already has an llms.txt, add our posts' lines to it instead of replacing it.
## 6. Check it's fresh
Compare your site with the API: the number of posts on `/blog` must match `total` from `GET {API}/html/posts`, and `/blog-sitemap.xml` must list the same posts as `GET {API}/sitemap`. If either is behind, something is caching for longer than 5 minutes: find it and fix it.
## 7. Finish in the dashboard
1. Check the **post address** matches your post page, e.g. `https://example.com/blog/{slug}`.
2. Open a live post on your site and press **Run health check**.
3. Connect **Google Search Console** on the same page: add our account with **Full** permission. After every publish we submit your blog sitemap to Google, and you see clicks and positions per post.
That's it. New and updated posts show up within 5 minutes.
Prefer to do it yourself? Read the simple guide.
Blog pages in your design
A blog index and post pages, rendered on your server so Google and AI crawlers read every word.
SEO done right
Title, description, canonical, Open Graph and structured data on every post.
Discoverable
A blog sitemap on your domain, AI crawlers allowed in robots.txt, llms.txt and IndexNow for fast indexing.
Live within 5 minutes
Your blog reads our API on each visit, so a new post appears within 5 minutes. No rebuilds, nothing to wire up.
No code access?
On WordPress, Webflow, Shopify, Wix or a site you can't edit, we'll connect it for you for a one-off fee.