
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI found some helpful information about importing Jekyll blogs to Sanity! While there isn't a specific official "markdown-to-sanity" plugin in Sanity's documentation, there are several proven approaches you can use to migrate your Jekyll content.
The best solution is to use @portabletext/block-tools, which is designed specifically for converting HTML to Sanity's Portable Text format. Since Jekyll posts are markdown with YAML front matter, here's the workflow:
gray-matter to extract front matter (title, date, etc.) and the markdown bodymarked@portabletext/block-toolsHere's a basic migration script structure:
import {JSDOM} from 'jsdom'
import {htmlToBlocks} from '@portabletext/block-tools'
import matter from 'gray-matter'
import {marked} from 'marked'
import fs from 'fs'
// Parse your Jekyll post
const fileContent = fs.readFileSync('your-post.md', 'utf-8')
const {data: frontMatter, content: markdown} = matter(fileContent)
// Convert markdown to HTML
const html = marked(markdown)
// Convert HTML to Portable Text blocks
const blocks = htmlToBlocks(html, blockContentSchema, {
parseHtml: (html) => new JSDOM(html).window.document,
rules: [
// Add custom rules for images, code blocks, etc.
{
deserialize(node, next, block) {
if (node.nodeName.toLowerCase() === 'img') {
return block({
_type: 'image',
url: node.getAttribute('src'),
alt: node.getAttribute('alt'),
})
}
return undefined
}
}
]
})A common issue when running migration scripts is module import errors. The solution is to run your script using Sanity's CLI:
sanity exec path/to/your-migration-script.js --with-user-tokenThis lets you use ES6 import syntax and access Sanity's libraries directly without configuration headaches.
For images in your posts, you'll need to:
The uploading assets efficiently guide covers this in detail.
If you can share the specific error message you're getting with the "markdown-to-sanity" plugin, I can help troubleshoot it! It might be a versioning issue, configuration problem, or the plugin might be outdated. The @portabletext/block-tools approach above is the current recommended method and is actively maintained by the Sanity team.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store