Overview
Icon for Blog & SEO

Blog & SEO

Multilingual blog with built-in SEO

medusa-blog-seo

A multilingual blog for Medusa v2 with SEO built in. Posts, categories and authors in any number of languages (configured, not hard-coded), per-language slugs with permanent redirects when they change, fallback rules, scheduled publishing, preview links, a rich editor with shoppable product cards, and helpers for JSON-LD, hreflang, sitemaps and RSS.
Blog multibahasa untuk Medusa v2 dengan SEO bawaan: tulisan, kategori, dan penulis dalam bahasa apa pun (diatur, bukan hard-code), slug per bahasa dengan redirect permanen, aturan fallback, publikasi terjadwal, tautan pratinjau, editor kaya dengan kartu produk, dan helper JSON-LD, hreflang, sitemap, RSS.

Compatibility

Plugin Medusa Node Tested in CI on 0.1.x 2.19.0 or newer 2.x (Copy to clipboard^2.19.0) 20.19+ or 22.12+ Medusa 2.19.0 and 2.22.2

Images go through the File Module (local, S3, R2, …). Copy to clipboardsharp is optional: when it is installed, uploads are turned upright, resized and stripped of EXIF data.

Quick start

npm install medusa-blog-seo
// medusa-config.ts
plugins: [
{
resolve: "medusa-blog-seo",
options: {
storefront_url: "https://your-store.com",
},
},
],
npx medusa db:migrate

Open Blog in the Admin sidebar. Add your languages under Settings (the default is one locale, Copy to clipboarden), write a post, publish it. The storefront reads Copy to clipboard/store/blog-seo/posts and Copy to clipboard/store/blog-seo/posts/{slug} with Copy to clipboard?locale=. Full steps: Installation · Languages · Options · Storefront (Next.js) · Store API · Limits.

English · Bahasa Indonesia

Posts Editor, side by side with the default language Languages

English

Features

Content

  • Posts with per-language title, slug, excerpt, body, meta title/description, sharing (OG) image, cover alt text and tags; shared cover (4:3) and wide cover (16:9), category, author, related products, one featured post.
  • Categories with name, slug and description per language; authors (person or organisation) with photo, website, profile links (Copy to clipboardsameAs), and job title and bio per language.
  • Rich editor in the Admin (Tiptap): headings, lists, quotes, links, tables, photos with alt and caption, YouTube embeds, product cards picked from the catalogue, and Q&A blocks. Bodies are sanitised server-side and rendered into blocks, a table of contents (from H2/H3) and FAQ items (an H3 ending in "?" and its paragraphs).
  • Draft → scheduled → published. A job (every 5 minutes, Copy to clipboardBLOG_SEO_PUBLISH_CRON to change it) publishes due posts. Drafts autosave in the Admin; published posts save on demand. The first public date is kept when a post is republished; Copy to clipboardcontent_updated_at moves on every public change.
  • Preview links per language with a secret token (renewable), showing drafts and incomplete translations.

Languages

  • Not hard-coded. The list of locales (BCP 47: Copy to clipboarden, Copy to clipboardid, Copy to clipboardpt-BR, Copy to clipboardar…), their names, text direction, order, the default locale and the fallback rule are set in Admin → Blog → Settings, or fixed in the plugin options (then the Admin shows them read-only).
  • Fallback per store: Copy to clipboarddefault (show the default language at that locale's address), Copy to clipboardlabel (same, and the storefront can say "not yet translated"), or Copy to clipboardhide (the post exists only in languages with a complete translation).
  • Completeness per language in the Admin (tabs, badges, a "missing in …" filter, side-by-side editing with the default language). A post can be published once its default-language translation is complete (and a cover, if Copy to clipboardpublish.require_cover); other languages become visible as they are completed.
  • Slug history. When a slug changes (edited by hand, or a locale that used to show the fallback gets its own translation), the old address is kept in Copy to clipboardbseo_post_slug_history and the Store API answers Copy to clipboard{ post: null, redirect: "<new slug>", status: 301 } for it. History always points at the post, never at another slug, so there are no chains or loops; a live slug always wins over a historical one.
  • Copy to clipboardhreflang and Copy to clipboardx-default maps, sitemap entries with alternates, an RSS feed per language, Copy to clipboard<html lang dir> values, and per-locale routing (path prefix or a separate origin per language).

Integration

  • Store API Copy to clipboard/store/blog-seo/*, Admin API Copy to clipboard/admin/blog-seo/*, a typed client (Copy to clipboardmedusa-blog-seo/sdk), SEO helpers (Copy to clipboardmedusa-blog-seo/seo), JSON-LD helpers (Copy to clipboardmedusa-blog-seo/jsonld).
  • Events Copy to clipboardblog_seo.post.published|updated|unpublished|deleted, Copy to clipboardblog_seo.category.changed, Copy to clipboardblog_seo.author.changed, Copy to clipboardblog_seo.settings.changed, with slugs (and previous slugs) per locale.
  • Revalidate webhook (optional): public changes are batched and POSTed to your storefront with a secret header, so it can revalidate or purge exactly the pages that changed.
  • Products are linked through a module link (Copy to clipboardproduct.bseo_posts in Query), so a product page can list the posts that feature it.
  • Admin texts in English and Indonesian (follows the Admin user's language).

Requirements

  • Medusa 2.19.0 or newer 2.x, PostgreSQL. Redis recommended (events, workflows).
  • The File Module for uploads (the default local provider works; S3/R2 for production). Copy to clipboardsharp optional.

Installation

  1. Copy to clipboardnpm install medusa-blog-seo (and Copy to clipboardnpm install sharp if you want uploads processed).
  2. Add the plugin to Copy to clipboardmedusa-config.ts (see Quick start). Copy to clipboardstorefront_url makes the Admin's "preview" and "public page" links absolute.
  3. Copy to clipboardnpx medusa db:migrate creates the tables Copy to clipboardbseo_settings, Copy to clipboardbseo_author, Copy to clipboardbseo_author_translation, Copy to clipboardbseo_category, Copy to clipboardbseo_category_translation, Copy to clipboardbseo_post, Copy to clipboardbseo_post_translation, Copy to clipboardbseo_post_slug_history and the post–product link table.
  4. Restart. The job Copy to clipboardblog-seo-publish-scheduled runs on the worker.
  5. In the Admin, open Blog → Settings and set your languages (unless you fixed them in the options).
Note for pnpm without hoisting or a locally linked copy: the Admin build picks up this plugin's Tailwind classes through Copy to clipboardrequire.resolve("medusa-blog-seo/admin") from Copy to clipboard@medusajs/admin-bundler; if the bundler cannot resolve the package (pnpm with Copy to clipboardhoist=false, or a plugin symlinked from outside the project), the plugin's Admin pages lose their layout. npm, Yarn and pnpm's defaults are fine; otherwise install from npm (or Copy to clipboardnpm pack) next to the bundler, or add Copy to clipboardhoist-pattern[]=medusa-blog-seo to Copy to clipboard.npmrc.

Languages and fallback

Every post has a translation row per language. The default locale is required for publishing; the others are optional and become visible as they are completed (title, excerpt, body). What a reader sees at a language that has no complete translation depends on Copy to clipboardfallback:

Copy to clipboardfallback Post list and post page in that language Copy to clipboardtranslated in the API Copy to clipboarddefault The default-language text at that language's address Copy to clipboardfalse Copy to clipboardlabel Same; the storefront can show a "not yet translated" note Copy to clipboardfalse Copy to clipboardhide The post is not listed and its address answers 404 –

A locale that shows the fallback uses the default locale's slug. When its own translation is completed, the slug changes to the translated one and the previous address is kept as a permanent redirect (see Slug history).

Locales can be given per store in the Admin, or fixed in the options:

options: {
locales: [{ code: "id", name: "Bahasa Indonesia" }, { code: "en" }, { code: "ar", dir: "rtl" }],
default_locale: "id",
fallback: "hide",
}

Names default to the language's own name (Copy to clipboardDeutsch, Copy to clipboard日本語), direction to Copy to clipboardrtl for Arabic, Hebrew, Persian and Urdu. Disabling a language in the Admin hides it from the store but keeps its text.

The locale of a Store request is taken from Copy to clipboard?locale=, then the Copy to clipboardx-medusa-locale header, then Medusa's own Copy to clipboardreq.locale, else the default. An exact match wins, then the same language (Copy to clipboarden-GB → Copy to clipboarden), else the default.

Plugin options

{
resolve: "medusa-blog-seo",
options: {
locales: [{ code: "id" }, { code: "en" }], // optional; given here they are locked in the Admin
default_locale: "id", // optional
fallback: "default", // "default" | "label" | "hide"
storefront_url: "https://your-store.com", // absolute preview / public links in the Admin
routing: {
locales: { en: { prefix: "/us" } }, // per locale: { prefix } or { origin: "https://example.de" }
base: "/blog", // blog root
category: "category", // /blog/category/{slug}
page: "page", // /blog/page/2
feed: "feed.xml", // /blog/feed.xml
preview: "preview", // /blog/preview/{token}
x_default: "en", // locale carrying hreflang="x-default" (default: default locale)
},
content: {
image_origins: ["https://cdn.your-store.com"], // extra origins allowed in <img src>; upload URLs are learned
site_hosts: ["your-store.com"], // links to these hosts are internal (no target=_blank)
faq_from_headings: true, // H3 ending in "?" + paragraphs → FAQ

Non-default locales get the path prefix Copy to clipboard/{code} unless Copy to clipboardrouting.locales[code].prefix says otherwise (Copy to clipboard"" for no prefix, or Copy to clipboardorigin for a separate domain). Copy to clipboardBLOG_SEO_PUBLISH_CRON (env) changes the publish job's schedule.

Storefront (Next.js)

The typed client works with Copy to clipboard@medusajs/js-sdk or any object with Copy to clipboardclient.fetch.

// lib/blog.ts
import Medusa from "@medusajs/js-sdk"
import { blogSeoStore } from "medusa-blog-seo/sdk"
import { blogUrls, hreflang, htmlAttributes, postRedirectUrl, sitemapEntries, rssFeed } from "medusa-blog-seo/seo"
import { postJsonLd } from "medusa-blog-seo/jsonld"
const sdk = new Medusa({ baseUrl: process.env.MEDUSA_BACKEND_URL!, publishableKey: process.env.MEDUSA_PUBLISHABLE_KEY! })
export const blog = blogSeoStore(sdk)
export const urls = async () => blogUrls((await blog.settings()).settings, process.env.SITE_URL)
// app/[locale]/blog/[slug]/page.tsx
import { notFound, permanentRedirect } from "next/navigation"
export default async function Post({ params }: { params: Promise<{ locale: string; slug: string }> }) {
const { locale, slug } = await params
const u = await urls()
const r = await blog.getPost(slug, locale) // 404 → throws; old slug → { redirect }
const to = postRedirectUrl(u, locale, r)
if (to) permanentRedirect(to) // old address → 301 to the new slug
if (!r.post) notFound()
const jsonLd = postJsonLd(u, locale, r.post, { organization: { name: "Your store", url: process.env.SITE_URL! } })
return (
<article dir={r.post.dir}>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
<h1>{r.post.title}</h1>
<div dangerouslySetInnerHTML={{ __html: r.post.body_html }} />
</article>
)
}

Copy to clipboardr.post.blocks is the body as typed blocks (paragraphs, headings, images, product cards with Copy to clipboardproduct_id, YouTube ids, tables, Q&A), for storefronts that render their own components instead of Copy to clipboardbody_html.

// app/sitemap.ts
export default async function sitemap() {
const [u, { posts }] = await Promise.all([urls(), blog.index()])
return sitemapEntries(u, posts, { images: true }) // one entry per post and locale, with hreflang alternates
}
// app/[locale]/blog/feed.xml/route.ts
export async function GET(_: Request, { params }) {
const { locale } = await params
const [u, { posts }] = await Promise.all([urls(), blog.index()])
return new Response(rssFeed(u, locale, posts, { title: "Your store blog", description: "…" }), { headers: { "content-type": "application/rss+xml" } })
}

Copy to clipboardhtmlAttributes(settings, locale) gives Copy to clipboard{ lang, dir } for Copy to clipboard<html>. Copy to clipboardblog.listPosts({ locale, category, author, tag, limit, offset }) answers the list page (the featured post is returned separately so pages never repeat it; Copy to clipboardfeatured: "none" turns that off). Copy to clipboardblog.preview(token, locale) renders a preview page; use Copy to clipboardcache: "no-store".

Revalidation. With Copy to clipboardrevalidate.url set, the backend POSTs (batched, Copy to clipboardx-revalidate-secret header):

{ "blog_seo": { "posts": [{ "id": "…", "slugs": { "id": "a", "en": "b" }, "previous_slugs": { "en": "old" }, "category_slugs": {}, "previous_category_slugs": {} }], "categories": ["…"], "all": false } }

Revalidate the post pages for Copy to clipboardslugs and Copy to clipboardprevious_slugs, the category pages, and the index when Copy to clipboardall is true.

Store API

Requires a publishable API key. Locale from Copy to clipboard?locale= / Copy to clipboardx-medusa-locale.

Method Path Answer GET Copy to clipboard/store/blog-seo/settings Copy to clipboard{ settings }: enabled locales (code, name, dir), default, fallback, routing, x_default GET Copy to clipboard/store/blog-seo/posts?locale=&category=&author=&tag=&featured=separate|none&limit=12&offset=0 Copy to clipboard{ posts, featured, category, count, limit, offset, locale } GET Copy to clipboard/store/blog-seo/posts?view=index Copy to clipboard{ posts }: every public post with slug/title/excerpt per readable locale (sitemap, feeds, llms.txt) GET Copy to clipboard/store/blog-seo/posts/{slug}?locale= Copy to clipboard{ post, more }, or Copy to clipboard{ post: null, redirect, status: 301, locale } for a previous slug, or 404 GET Copy to clipboard/store/blog-seo/categories?locale= Copy to clipboard{ categories, locale } with Copy to clipboardpost_count and Copy to clipboardalternates GET Copy to clipboard/store/blog-seo/authors?locale=, Copy to clipboard/store/blog-seo/authors/{slug} authors with job title and bio in the locale GET Copy to clipboard/store/blog-seo/preview/{token}?locale= Copy to clipboard{ post, more } for any status, incomplete translations included

A post answers Copy to clipboardlocale, Copy to clipboardtranslated (false when shown through the fallback), Copy to clipboarddir, Copy to clipboardalternates (slug per locale that can be read), Copy to clipboardbody_html, Copy to clipboardblocks, Copy to clipboardtoc, Copy to clipboardfaq, Copy to clipboardreading_minutes, Copy to clipboardtags, Copy to clipboardproduct_ids, Copy to clipboardcategory, Copy to clipboardauthor, SEO fields. Errors are Copy to clipboard{ type, code, message } with HTTP 404 / 400 / 409 (Copy to clipboardslug_taken) / 403 (Copy to clipboardlocked).

Admin API

Copy to clipboard/admin/blog-seo/settings (GET/POST), Copy to clipboard/config (GET), Copy to clipboard/posts (GET with Copy to clipboardstatus, Copy to clipboardcategory_id, Copy to clipboardauthor_id, Copy to clipboardmissing_locale, Copy to clipboardq, Copy to clipboardlimit, Copy to clipboardoffset; POST), Copy to clipboard/posts/{id} (GET/POST/DELETE), Copy to clipboard/posts/{id}/publish (POST Copy to clipboard{ at }: a future date schedules), Copy to clipboard/posts/{id}/unpublish, Copy to clipboard/posts/{id}/preview-token, Copy to clipboard/categories, Copy to clipboard/categories/{id}, Copy to clipboard/authors, Copy to clipboard/authors/{id}, Copy to clipboard/uploads (POST JSON Copy to clipboard{ filename, data: "data:image/…", kind } or multipart Copy to clipboardfiles). Copy to clipboardblogSeoAdmin(sdk) in Copy to clipboardmedusa-blog-seo/sdk wraps them.

Limits

  • The index view (Copy to clipboard?view=index), sitemap and RSS helpers, slug lookups and category counts load up to 5000 public posts into memory per request. That covers most shops' blogs; above that, paginate Copy to clipboardlistPosts and build sitemaps from it instead of Copy to clipboardindex().
  • Bodies are capped at Copy to clipboardcontent.max_body_bytes (2 MiB by default) after sanitising; images at Copy to clipboarduploads.max_bytes (25 MiB) and Copy to clipboardmax_side (2400 px).
  • Related products per post: 12. Tags per translation: 20, lower-case.
  • Category and author pages, tags and search are per locale; there is no cross-locale search.

FAQ

Can I use it in one language? Yes. The default settings are one locale, Copy to clipboarden; the Admin shows one tab.

I write in Indonesian and translate some posts to English. What should I set? Locales Copy to clipboardid (default) and Copy to clipboarden, Copy to clipboardfallback: "hide" if untranslated posts must not appear under Copy to clipboard/en at all, Copy to clipboard"default" or Copy to clipboard"label" if they should appear in Indonesian until translated. In every case the English address redirects permanently once the translation is complete.

Does changing a slug break links? No. Old slugs stay as permanent redirects, per language.

Where are images stored? In the File Module (the one configured in your Copy to clipboardmedusa-config.ts). The Admin shows only images from the File Module's origin and Copy to clipboardcontent.image_origins.

Does it conflict with another blog module? Tables are Copy to clipboardbseo_*, the module key is Copy to clipboardblogSeo, routes are Copy to clipboard/blog-seo/*, the Admin route is Copy to clipboard/blog-seo: it can run next to an existing blog while you migrate.

Bahasa Indonesia

Fitur

  • Tulisan dengan judul, slug, ringkasan, isi, meta title/description, gambar berbagi (OG), teks alt sampul, dan tag per bahasa; sampul 4:3 dan 16:9, kategori, penulis, produk terkait, satu tulisan unggulan.
  • Kategori (nama, slug, deskripsi per bahasa) dan penulis (orang/organisasi, foto, situs, tautan profil, jabatan dan bio per bahasa).
  • Editor kaya di Admin: heading, daftar, kutipan, tautan, tabel, foto dengan alt dan keterangan, YouTube, kartu produk dari katalog, blok tanya-jawab. Isi disanitasi di server, jadi blok, daftar isi (H2/H3), dan FAQ (H3 berakhiran "?" + paragrafnya).
  • Draf → terjadwal → terbit lewat job tiap 5 menit (Copy to clipboardBLOG_SEO_PUBLISH_CRON). Draf tersimpan otomatis; tulisan terbit disimpan saat menekan Simpan. Tanggal terbit pertama dipertahankan saat diterbitkan ulang.
  • Tautan pratinjau per bahasa dengan token rahasia (bisa diperbarui).
  • Bahasa tidak di-hardcode: daftar locale (BCP 47), nama, arah teks, urutan, bahasa utama, dan aturan fallback diatur di Admin → Blog → Pengaturan atau dikunci lewat opsi plugin.
  • Fallback Copy to clipboarddefault (tampilkan bahasa utama di alamat bahasa itu), Copy to clipboardlabel (sama, storefront bisa memberi catatan "belum diterjemahkan"), atau Copy to clipboardhide (tulisan hanya ada di bahasa yang terjemahannya lengkap).
  • Kelengkapan per bahasa di Admin: tab, badge, filter "belum ada …", edit berdampingan dengan bahasa utama. Tulisan bisa terbit begitu terjemahan bahasa utamanya lengkap; bahasa lain muncul begitu lengkap.
  • Riwayat slug: slug yang berubah (diedit, atau bahasa yang tadinya fallback dapat terjemahan sendiri) disimpan di Copy to clipboardbseo_post_slug_history; Store API menjawab Copy to clipboard{ post: null, redirect: "<slug baru>", status: 301 } untuk slug lama. Riwayat selalu menunjuk ke tulisan, bukan slug lain: tidak ada rantai atau loop; slug yang masih hidup selalu menang.
  • Copy to clipboardhreflang + Copy to clipboardx-default, sitemap dengan alternates, RSS per bahasa, Copy to clipboard<html lang dir>, routing per locale (prefix path atau domain terpisah).
  • Store API Copy to clipboard/store/blog-seo/*, Admin API Copy to clipboard/admin/blog-seo/*, klien bertipe (Copy to clipboardmedusa-blog-seo/sdk), helper SEO (Copy to clipboardmedusa-blog-seo/seo) dan JSON-LD (Copy to clipboardmedusa-blog-seo/jsonld), event Copy to clipboardblog_seo.*, webhook revalidate (opsional, batch), link produk (Copy to clipboardproduct.bseo_posts). Teks Admin dalam Inggris dan Indonesia.

Pasang

npm install medusa-blog-seo # + npm install sharp kalau mau gambar diproses
// medusa-config.ts
plugins: [
{
resolve: "medusa-blog-seo",
options: {
locales: [{ code: "id" }, { code: "en" }], // opsional; kalau diisi, terkunci di Admin
default_locale: "id",
fallback: "hide",
storefront_url: "https://toko-anda.com",
routing: { locales: { en: { prefix: "/us" } } },
},
},
],
npx medusa db:migrate

Buka Blog di sidebar Admin. Tabel opsi lengkap: Plugin options. Contoh storefront Next.js (halaman tulisan dengan redirect slug lama, metadata + hreflang, sitemap, RSS): Storefront (Next.js). Batasan (5000 tulisan di memori untuk index/sitemap/RSS, ukuran isi dan gambar): Limits.

Catatan untuk pnpm tanpa hoisting atau plugin yang di-symlink lokal: build Admin mengambil class Tailwind plugin ini lewat Copy to clipboardrequire.resolve("medusa-blog-seo/admin") dari Copy to clipboard@medusajs/admin-bundler; kalau bundler tidak bisa me-resolve paketnya (pnpm dengan Copy to clipboardhoist=false, atau plugin di-symlink dari luar proyek), halaman Admin plugin kehilangan layout-nya. npm, Yarn, dan pnpm bawaan aman; selain itu pasang dari npm (atau Copy to clipboardnpm pack) di sebelah bundler, atau tambahkan Copy to clipboardhoist-pattern[]=medusa-blog-seo di Copy to clipboard.npmrc.

Alur

  1. Tulis draf di Admin (tersimpan otomatis), isi bahasa utama sampai lengkap, bahasa lain menyusul.
  2. Terbitkan sekarang atau jadwalkan; job menerbitkan saat waktunya tiba dan memancarkan Copy to clipboardblog_seo.post.published.
  3. Storefront membaca Copy to clipboard/store/blog-seo/posts/{slug}?locale=; slug lama dijawab Copy to clipboardredirect → redirect 301.
  4. Dengan Copy to clipboardrevalidate.url, backend mengirim daftar slug (baru dan lama) yang berubah supaya storefront me-revalidate halaman yang tepat.

Development

npm ci
npm run build
npm run lint && npm run typecheck && npm run test:unit
npm run test:e2e # Postgres on the spike port, see CONTRIBUTING.md

The end-to-end suite starts Medusa with the plugin, creates languages, posts, categories and authors through the Admin API, uploads images, publishes and schedules, and checks the Store API (fallback modes, redirects for old slugs, preview, index view, product links) and the revalidate webhook, on Medusa 2.19.0 and 2.22.2 in CI.

Built for hauskayu.com

Built and used in production by Haus Kayu, handmade teak homeware from Jepara. The blog there (Indonesian with English translations) runs on this plugin.

Other plugins by Haus Kayu

Support

  • Issues and feature requests: GitHub issues
  • E-mail: dev@hauskayu.com

License

MIT © Haus Kayu

You may also like

Browse all integrations

Build your own

Develop your own custom integration

Build your own integration with our API to speed up your processes. Make your integration available via npm for it to be shared in our Library with the broader Medusa community.

gift card interface

Ready to build your custom commerce setup?