Connect: simple
- Before you start: your blog must stay fresh
- What you need
- 1. Blog page
- 2. Post page
- 3. Blog sitemap on your site
- 4. IndexNow key file
- 5. llms.txt
- 6. Check it's fresh
- 7. Finish in the dashboard
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 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 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 } }(orcache: 'no-store'), orexport const revalidate = 300on each blog route, the sitemap route included. Nevercache: 'force-cache', and neverunstable_cacheor'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-Controlheaders and any CDN rules on/blogand/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.envlocally, 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 leaveruntimeConfig's value empty and setNUXT_BLOGSFORSEO_API_KEYwhen the server starts; writingprocess.env.BLOGSFORSEO_API_KEYintoruntimeConfigbakes 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
headinside 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), usemetainstead: it holds the same values (its fields). - Put
bodyin 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
- Check the post address matches your post page, e.g.
https://example.com/blog/{slug}. - Open a live post on your site and press Run health check.
- 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.