blogsforseo

Connect: advanced

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 as Authorization: Bearer <key>, from your server only. Without it the API answers 401.
  • BLOGSFORSEO_API_URL: optional, defaults to https://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:

  1. title as the <h1>. Under it: author.name, publishedAt, updatedAt (when different) and readingMinutes.
  2. heroImage, when present, with its alt, width and height.
  3. shortAnswer in a highlighted box, then keyTakeaways as a list.
  4. A table of contents from toc ({ id, text, level }, linking to #id), when it has 3 or more entries.
  5. bodyHtml, inserted as raw HTML. It is already sanitised; don't escape it, and keep its heading ids and links.
  6. faqs, sources (as links) and related (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> from metaTitle
  • <meta name="description"> from metaDescription
  • <link rel="canonical"> from canonicalUrl, when it isn't null
  • Open Graph tags: og:title, og:description, og:image (the hero image) and og:type set to article
  • <script type="application/ld+json"> holding JSON.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 from GET {API}/sitemap ([{ url, lastmod }]) plus your blog index, refreshed like the blog pages (GET {API}/sitemap?format=xml is a finished one). Never change your root /sitemap.xml. Add Sitemap: https://<your domain>/blog-sitemap.xml to 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.txt yet: serve GET {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:

  1. curl -A GPTBot https://your-site/blog returns 200 and lists your posts, or shows the empty state.
  2. curl -A GPTBot <a post URL> returns raw HTML with the <h1>, the body text, the canonical link, the meta description and the application/ld+json script.
  3. A post URL with a made-up slug returns 404.
  4. /blog-sitemap.xml, /robots.txt, /llms.txt and /{INDEXNOW_KEY}.txt are all correct.
  5. The number of posts on /blog matches total from GET {API}/posts, and /blog-sitemap.xml lists the same posts as GET {API}/sitemap. If either is behind, a cache is holding it for more than 5 minutes.

9. Finish in the dashboard

  1. Check the post address matches the exact pattern your site uses.
  2. Press Run health check. The health check loads a live post the way AI crawlers do, and lists anything left to fix.
  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.