
Short answer: Prismic does not publish an RSS feed for your site, but its content API gives you everything a feed needs. Query the newest published documents of your blog type with the official client, turn each document into an item with an absolute link, the first publication date and an excerpt field, escape the text, send the RSS content type and a cache validator and test the live address. Refresh the feed when a document is published, and connect the address to an auto-poster so that every new article reaches your social channels.
Prismic is a headless content management system. Editors write documents in a visual page builder, and developers read them through an API and render them in any front end. The separation is a strength, but nothing in Prismic knows what your page addresses look like, so it cannot create a feed on its own. The feed has to be written in your own project, from the API data, and it must use the same addresses, the same unique identifiers and the same dates as your pages. This guide builds a feed handler, explains the fields that matter and ends with a test routine.
A feed item needs a title, a permanent address, a date and a summary. In Prismic each document of a custom type, for example a blog post, carries a unique identifier called the UID, which is usually used in the page address. The title and the summary are fields you define in the type, and the dates come from the document itself.
| Feed element | Source in Prismic | Rule |
|---|---|---|
| Title | title field of the type | Plain text, not the rich text structure |
| Link and identifier | uid and the site address | Absolute, https, never changes |
| Publication date | first_publication_date | The first time the document went live |
| Description | an excerpt field | One or two complete sentences |
| Image | an image field | Absolute address with a type |
Use the first publication date and not the date of the last publication. An editor who fixes a typo in an old article publishes the document again, and a feed that used the last date would move the item to the top and make an auto-poster share the article twice. The causes and cures of repeated posts are covered in why a feed auto-posts the same article twice.
The official JavaScript client reads the master version of the repository, which contains only published documents. Ask for the blog type, newest first and a limited number, and keep the repository name in an environment variable.
// server-side module, for example lib/feed.js
import * as prismic from "@prismicio/client";
const SITE = "https://example.com";
const client = prismic.createClient(process.env.PRISMIC_REPOSITORY, { fetch });
export async function loadPosts() {
const response = await client.getByType("blog_post", {
pageSize: 20,
orderings: [{ field: "document.first_publication_date", direction: "desc" }],
});
return response.results;
}The package name, the helper functions and the ordering syntax can change between versions, so check them in the documentation of the version you use. If your repository is private, the client also accepts an access token, which must stay on the server. The same approach for other headless systems is covered in the Sanity feed guide, the Contentful feed guide és the Strapi feed guide.
Text from a content system can contain ampersands, angle brackets and quotation marks, and any of them can break an XML document. Escape every value before it goes into the template. Titles in Prismic are stored as structured rich text, so convert them to plain text first.
const ENT = {
"&": "&" + "amp;",
"<": "&" + "lt;",
">": "&" + "gt;",
'"': "&" + "quot;",
"'": "&" + "apos;",
};
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ENT[c]);
export function render(posts) {
const newest = posts.length ? new Date(posts[0].first_publication_date) : new Date(0);
const items = posts.map((p) => {
const url = `${SITE}/blog/${p.uid}/`;
return `<item>
<title>${esc(prismic.asText(p.data.title))}</title>
<link>${esc(url)}</link>
<guid isPermaLink="true">${esc(url)}</guid>
<pubDate>${new Date(p.first_publication_date).toUTCString()}</pubDate>
<description>${esc(p.data.excerpt)}</description>
</item>`;
}).join("\n");
return `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel>
<title>Example Journal</title>
<link>${SITE}</link>
<description>News and guides from Example Journal.</description>
<lastBuildDate>${newest.toUTCString()}</lastBuildDate>
${items}
</channel></rss>`;
}Several details are deliberate. The date method of the language writes the format that the RSS specification expects. The channel date comes from the newest document and not from the clock, so that the file does not change when nothing was published. The identifier of each item is its permanent address, and the address is built from the UID and a fixed constant, so every link is absolute. If your site maps documents to addresses with a route resolver, use the same function in the feed and on the website, so that the two can never disagree.
The route handler sets the content type, a cache lifetime and a validator, and it answers with a 304 status when the client already holds the current version.
import { createHash } from "node:crypto";
export async function GET(request) {
const xml = render(await loadPosts());
const etag = '"' + createHash("sha1").update(xml).digest("hex") + '"';
const headers = {
"Content-Type": "application/rss+xml; charset=utf-8",
"Cache-Control": "public, max-age=300",
ETag: etag,
};
if (request.headers.get("if-none-match") === etag) {
return new Response(null, { status: 304, headers });
}
return new Response(xml, { status: 200, headers });
}The validator is a hash of the finished document, so it changes exactly when the content changes. A 304 answer saves bandwidth for you and for every tool that polls the feed. The mechanism is explained in the guide to ETags and conditional requests, and the status codes in the guide to feed status codes.
A feed cached for a few minutes is fine, but you can make it faster. Prismic can call a webhook when documents are published or unpublished. Point that webhook at a small endpoint that clears the cached copy of the feed, or rebuilds the site, and a new article appears within seconds. Keep a short cache lifetime as a safety net, because a webhook can fail without anyone noticing. Test the whole chain by publishing a draft and watching the feed, since a stale feed delays every social post.
Prismic lets teams group changes into releases and publish them together. Content that sits in a release is not part of the master version until the release is published, which is exactly what a feed needs: the feed shows only what readers can see. Never point a public feed at a preview or a release reference, because unpublished text would be shared on social networks before it exists on your website. If you import old articles, keep their original dates in a field of your own and map them in the feed, because a feed full of items with today’s date makes an auto-poster share the whole archive in one afternoon. For the effect of old dates see the guide to feed order and backdated posts.
Auto-posters build the best social posts from a feed that gives them a short summary and a picture. Make the excerpt a required field, so that no article reaches the feed without one, and write complete sentences instead of cutting the body automatically. If a document has an image, add it as an enclosure with an absolute address, a type and a length. Image addresses from the API are absolute, but they can carry resizing parameters, so fix the width you want in the address. Text arrives as Unicode and the response declares UTF-8, but control characters that XML forbids can still come from pasted content. See why special characters and emoji break feeds.
Prismic repositories can hold documents in more than one locale. A feed should contain one language only, because a social channel is usually written for one audience. Pass the locale to the query, for example the language code of your main site, and build a second feed for each other language with its own address and its own channel. Never mix translations in one feed, since an auto-poster would share the same story in two languages one after the other and readers would see it as a duplicate.
People and tools should not have to guess where the feed is. Add a link element to the head of your site layout, with the relation set to alternate, the type set to the RSS media type and the absolute address of the feed. In most front end frameworks this goes into the metadata of the root layout. A visitor or a tool that only knows your home page can then find the feed on its own. The full explanation is in the guide to feed autodiscovery.
Request the route locally, then test the deployed address from outside, because a local test says nothing about the hosting platform and the certificate in front of your application.
curl -i http://localhost:3000/feed.xml
curl -i https://example.com/feed.xml
curl -i -H 'If-None-Match: "paste-the-etag-here"' https://example.com/feed.xmlA longer routine is in the feed validation guide, and a shorter one in debugging a feed with curl.
PostRSS has been publishing RSS and Atom feeds to social networks since 2014. Paste the address of your feed, connect your accounts and choose how each post is built from the title, the description or the page title. PostRSS checks the feed as often as every minute and shares each new entry, with its image and link, to the channels you choose among 66 supported networks, messengers, team chats and blogs, including LinkedIn, X, Bluesky, Mastodon and Telegram. Keyword filters, UTM parameters and posting windows let you tune each channel. See the PostRSS features page and the plan limits on the pricing page. More developer guides are under the Technical Guide tag.
A Prismic feed is a small handler written in your own project, and it has to get the details right: the published version of the repository, the first publication date, a required excerpt field, UIDs that match your page addresses, plain text titles, escaped text, absolute links, the correct content type and a validator that lets clients skip unchanged files. Refresh it with a webhook, test the live address with curl and a validator, then connect it to an auto-poster. After that, every article your editors publish reaches your readers and your social channels without extra work.
No. Prismic delivers content through its API, so you build the feed in your own project from the documents that the API returns.
The first publication date. The last publication date changes whenever an editor republishes and would push old articles to the top of the feed.
Convert the structured title to plain text with the helper of the client library, then escape it before it goes into the XML.
Set up a webhook for publish events that clears the cached feed or triggers a rebuild, and keep a short cache lifetime as a safety net.
Yes. PostRSS reads any valid RSS or Atom address that is reachable without a login. Paste the address, connect your channels and new articles are shared as soon as they appear.
What changed in the networks, what broke, and how to fix it before it costs you reach.
Az Internet Solutions, a PostRSS mögött álló csapat fejlesztései. Mindegyik a maga módján spórol időt.