Connect: advanced
- What you need
- 1. Config
- 2. Blog index page
- 3. Post page
- 4. Caching
- 5. Sitemap and robots.txt
- 6. llms.txt
- 7. IndexNow key file
- 8. Check it
- 9. Finish in the dashboard
The advanced way: your site gets each post as data and builds every part of the page itself. You get full control of the markup, and also the full job: SEO tags, structured data, sitemap and the rest.
Most sites should use the simple way instead. There, we send finished HTML and you only style it.
Using a coding agent? On your dashboard's "Connect your website" page, choose Advanced and copy the prompt.
What you need
From your dashboard's "Connect your website" page:
| Value | What it is | Secret? |
|---|---|---|
| API key | Starts with bfs_; sent with every API request, and says which website you are |
Yes: keep it in an env var on your server |
| Sitemap line | The robots.txt line for /blog-sitemap.xml on your own domain |
No |
| Post URL pattern | Where posts live, e.g. https://example.com/blog/{slug} |
No |
| IndexNow key | 32 characters; lets search engines hear about new posts | No |
Set the post URL pattern in the dashboard first: canonical URLs, structured data and internal links are all built from it.
In this guide, {API} means https://blogsforseo.com/api/v1.
1. Config
BLOGSFORSEO_API_KEY(required, secret): sent on every request asAuthorization: Bearer <key>, from your server only. Without it the API answers 401.BLOGSFORSEO_API_URL: optional, defaults tohttps://blogsforseo.com.
Never hardcode the key.
Everything below is plain HTTP and JSON, so any language works. Field details are in the Content API reference, and the framework guides show the requests and routes in Next.js, React Router, Astro, Nuxt, SvelteKit, Laravel, Django and Rails, and jsonLd escaping in each language.
2. Blog index page
GET {API}/posts?page=1&pageSize=12 returns { posts, page, totalPages, total }, newest first. pageSize can be up to 50.
Show a card for each post, linking to its URL. Add pagination, and an empty state for when nothing is published yet.
3. Post page
Serve posts at your post URL pattern, and fetch each one with GET {API}/posts/{slug}.
- Missing posts: when the API returns 404, your page must return a real 404 status.
- Server rendering: the title and body must be in the raw HTML response. Client-side fetching alone fails, because AI crawlers don't run JavaScript. On a single-page app, render the blog pages on the server, or fetch through your own server route so the key stays on the server.
Render the post in this order:
titleas the<h1>. Under it:author.name,publishedAt,updatedAt(when different) andreadingMinutes.heroImage, when present, with itsalt,widthandheight.shortAnswerin a highlighted box, thenkeyTakeawaysas a list.- A table of contents from
toc({ id, text, level }, linking to#id), when it has 3 or more entries. bodyHtml, inserted as raw HTML. It is already sanitised; don't escape it, and keep its heading ids and links.faqs,sources(as links) andrelated(links to related posts).
Style the body's h2, h3, p, ul, ol, table, blockquote, a, img and code to match your site.
In <head>:
<title>frommetaTitle<meta name="description">frommetaDescription<link rel="canonical">fromcanonicalUrl, when it isn't null- Open Graph tags:
og:title,og:description,og:image(the hero image) andog:typeset toarticle <script type="application/ld+json">holdingJSON.stringify(post.jsonLd), with every<replaced by\u003c
Some frameworks stream metadata after the body to bots they don't recognise. If yours does, make sure GPTBot, ClaudeBot, PerplexityBot and Googlebot get it in <head>.
4. Caching
Your blog pages must fetch from the API on every visit, on your server: that's how new posts reach your site without a rebuild. The one rule for caching: nothing may keep our API's answer for more than 5 minutes. That covers page caches, fetch caches, data caches and your CDN, on the blog pages and the blog sitemap alike. In Next.js: { next: { revalidate: 300 } } on every fetch (or export const revalidate = 300 per route); never cache: 'force-cache', and never unstable_cache or 'use cache' with a longer lifetime. In Django, Laravel or Rails: no cache_page, Cache::remember or Rails.cache lifetime over 300 seconds.
Site built once, ahead of time (Next.js output: 'export', Gatsby, Hugo, Jekyll, Eleventy, Astro without a server)? It never asks the API again after deploying, so new posts never appear. Switch the blog pages to render on each request: in Next.js remove output: 'export' and use export const revalidate = 300; in Astro, Nuxt, SvelteKit or Remix turn on server rendering with your host's adapter. That needs a host that runs server code (Vercel, Netlify, Cloudflare, a Node server), not plain file hosting. Never fetch posts in the browser instead: AI crawlers wouldn't see them.
5. Sitemap and robots.txt
- Blog sitemap: a separate file on your domain,
/blog-sitemap.xml, built fromGET {API}/sitemap([{ url, lastmod }]) plus your blog index, refreshed like the blog pages (GET {API}/sitemap?format=xmlis a finished one). Never change your root/sitemap.xml. AddSitemap: https://<your domain>/blog-sitemap.xmlto robots.txt, next to your existing Sitemap lines. - robots.txt: it must not block Googlebot, Bingbot, OAI-SearchBot, ChatGPT-User, Claude-User, Claude-SearchBot, PerplexityBot or Perplexity-User. Blocking GPTBot or ClaudeBot only affects AI training, not citations, so that's your choice.
6. llms.txt
- No
/llms.txtyet: serveGET {API}/llms.txt(plain text) at/llms.txt. - Already have one: add a "Blog" section that links each post.
7. IndexNow key file
Serve /{INDEXNOW_KEY}.txt at your site root. Its body must be exactly the key, sent as text/plain. Once it's there, we notify Bing (which ChatGPT search also uses) within minutes of every publish.
8. Check it
Run these checks against your site:
curl -A GPTBot https://your-site/blogreturns 200 and lists your posts, or shows the empty state.curl -A GPTBot <a post URL>returns raw HTML with the<h1>, the body text, the canonical link, the meta description and theapplication/ld+jsonscript.- A post URL with a made-up slug returns 404.
/blog-sitemap.xml,/robots.txt,/llms.txtand/{INDEXNOW_KEY}.txtare all correct.- The number of posts on
/blogmatchestotalfromGET {API}/posts, and/blog-sitemap.xmllists the same posts asGET {API}/sitemap. If either is behind, a cache is holding it for more than 5 minutes.
9. Finish in the dashboard
- Check the post address matches the exact pattern your site uses.
- Press Run health check. The health check loads a live post the way AI crawlers do, and lists anything left to fix.
- 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.