Top Related Projects
Vite & Vue powered static site generator.
The web framework for content-driven websites. ⭐️ Star to support our work!
A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
The best React-based framework with performance, scalability and security built in.
The world’s fastest framework for building websites.
Quick Overview
Markdoc is a powerful, flexible, and lightweight markup language and authoring framework. It extends Markdown with custom syntax for creating rich, interactive documentation and content. Markdoc is designed to be easily integrated into existing websites and applications, making it ideal for technical documentation, content management systems, and other documentation-heavy projects.
Pros
- Extends Markdown with custom tags and attributes for enhanced functionality
- Easily integrates with existing web frameworks and static site generators
- Provides a powerful validation system to ensure content consistency
- Offers a flexible rendering system that can output to various formats
Cons
- Learning curve for custom syntax and configuration
- Limited ecosystem compared to more established documentation tools
- May require additional setup and configuration for complex use cases
- Documentation could be more comprehensive for advanced features
Code Examples
- Basic Markdoc syntax:
# Welcome to Markdoc
This is a {% tag name="custom" %} tag.
{% if variable %}
Conditional content
{% /if %}
- Defining a custom tag:
export const tags = {
callout: {
render: 'Callout',
attributes: {
type: {
type: String,
default: 'note',
},
},
},
};
- Using a custom tag in Markdoc:
{% callout type="warning" %}
This is a warning callout.
{% /callout %}
Getting Started
To get started with Markdoc, follow these steps:
- Install Markdoc:
npm install @markdoc/markdoc
- Create a basic Markdoc file (e.g.,
example.md
):
# Hello, Markdoc!
This is a {% tag name="custom" %} example.
- Parse and render the Markdoc content:
import Markdoc from '@markdoc/markdoc';
const source = '# Hello, Markdoc!\n\nThis is a {% tag name="custom" %} example.';
const ast = Markdoc.parse(source);
const content = Markdoc.transform(ast);
const html = Markdoc.renderers.html(content);
console.log(html);
This will output the rendered HTML content. For more advanced usage and configuration, refer to the official Markdoc documentation.
Competitor Comparisons
Vite & Vue powered static site generator.
Pros of VitePress
- Built on Vue.js, offering a powerful and flexible component system
- Leverages Vite for fast development and build times
- Includes built-in search functionality and customizable themes
Cons of VitePress
- Steeper learning curve for those unfamiliar with Vue.js
- Less flexibility in content structure compared to Markdoc's schema-based approach
- Limited to Vue.js ecosystem, potentially restricting integration with other frameworks
Code Comparison
VitePress:
<script setup>
import { useData } from 'vitepress'
const { page } = useData()
</script>
<template>
<h1>{{ page.title }}</h1>
</template>
Markdoc:
import { Markdoc } from '@markdoc/markdoc';
const content = `# {% $title %}`;
const ast = Markdoc.parse(content);
const rendered = Markdoc.transform(ast, { variables: { title: 'Hello' } });
VitePress uses Vue.js components for templating, while Markdoc employs a custom syntax for content generation. VitePress offers a more integrated approach within the Vue ecosystem, whereas Markdoc provides greater flexibility in terms of content structure and schema definition.
The web framework for content-driven websites. ⭐️ Star to support our work!
Pros of Astro
- Full-featured static site generator with built-in components and routing
- Supports multiple frontend frameworks (React, Vue, Svelte, etc.) in the same project
- Optimized performance with partial hydration and zero-JS by default
Cons of Astro
- Steeper learning curve due to its comprehensive feature set
- May be overkill for simple documentation projects
- Less focused on pure Markdown-based content compared to Markdoc
Code Comparison
Astro component:
---
const { title } = Astro.props;
---
<h1>{title}</h1>
<slot />
Markdoc component:
{% component 'Heading' %}
{{ title }}
{% /component %}
{{ children }}
Key Differences
- Astro is a full-fledged static site generator, while Markdoc focuses on Markdown-based content
- Astro supports multiple frontend frameworks, whereas Markdoc is framework-agnostic
- Astro has a more complex build process, while Markdoc offers simpler integration
Use Cases
- Astro: Ideal for complex websites with interactive components and multiple framework requirements
- Markdoc: Better suited for documentation-heavy projects and content-focused sites with minimal interactivity
A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
Pros of Eleventy
- More flexible and customizable, supporting multiple template languages
- Larger community and ecosystem, with more plugins and resources available
- Better performance for larger sites due to its static site generation approach
Cons of Eleventy
- Steeper learning curve, especially for beginners
- Requires more configuration and setup compared to Markdoc's simplicity
- Less focused on documentation-specific features out of the box
Code Comparison
Markdoc:
# Welcome to Markdoc
This is a {% $variable %} example.
{% if condition %}
Conditional content
{% /if %}
Eleventy:
---
layout: base.njk
---
<h1>Welcome to Eleventy</h1>
<p>This is a {{ variable }} example.</p>
{% if condition %}
<p>Conditional content</p>
{% endif %}
Summary
Eleventy is a more versatile static site generator with broader applications, while Markdoc is specifically designed for documentation sites. Eleventy offers greater flexibility and customization options but requires more setup and knowledge. Markdoc provides a simpler, more focused approach to documentation, making it easier for beginners to get started but potentially limiting for complex projects.
The best React-based framework with performance, scalability and security built in.
Pros of Gatsby
- Extensive ecosystem with a wide range of plugins and themes
- Built-in performance optimizations, including image processing and lazy loading
- Strong community support and extensive documentation
Cons of Gatsby
- Steeper learning curve, especially for developers new to React or GraphQL
- Can be overkill for simple static sites or small projects
- Slower build times for large sites compared to simpler static site generators
Code Comparison
Markdoc example:
# {% $markdoc.frontmatter.title %}
{% if $markdoc.frontmatter.description %}
{{ $markdoc.frontmatter.description }}
{% /if %}
{% block content %}{% /block %}
Gatsby example:
import React from "react"
import { graphql } from "gatsby"
export default function Template({ data }) {
const { markdownRemark } = data
const { frontmatter, html } = markdownRemark
return (
<div>
<h1>{frontmatter.title}</h1>
<div dangerouslySetInnerHTML={{ __html: html }} />
</div>
)
}
export const pageQuery = graphql`
query($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
title
}
}
}
`
The world’s fastest framework for building websites.
Pros of Hugo
- Mature and feature-rich static site generator with a large ecosystem
- Extremely fast build times, especially for large sites
- Supports multiple content formats (Markdown, HTML, AsciiDoc, etc.)
Cons of Hugo
- Steeper learning curve due to its extensive feature set
- Template syntax can be complex for beginners
- Less flexibility for custom rendering compared to Markdoc
Code Comparison
Hugo (Go templates):
{{ range .Pages }}
<h2>{{ .Title }}</h2>
{{ .Content }}
{{ end }}
Markdoc (React components):
import { Markdown } from '@markdoc/markdoc';
function Page({ content }) {
return <Markdown content={content} />;
}
Key Differences
- Hugo is a full-featured static site generator, while Markdoc is primarily a Markdown parser and renderer
- Hugo uses Go templates for templating, whereas Markdoc integrates with React components
- Hugo generates static HTML files, while Markdoc can be used in both static and dynamic environments
Use Cases
- Hugo: Ideal for large static websites, blogs, and documentation sites
- Markdoc: Well-suited for dynamic documentation, especially when integrated with React applications
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A powerful, flexible, Markdown-based authoring framework.
Markdoc is a Markdown-based syntax and toolchain for creating custom documentation sites and experiences.
We designed Markdoc to power Stripe's public docs, our largest and most complex content site.
Installation
To get started with Markdoc, first install the library:
npm install @markdoc/markdoc
or
yarn add @markdoc/markdoc
and import it in your app:
const Markdoc = require('@markdoc/markdoc');
or if you are using ESM
import Markdoc from '@markdoc/markdoc';
then use Markdoc
in your app or tool:
const doc = `
# Markdoc README
{% image src="/logo.svg" /%}
`;
const ast = Markdoc.parse(doc);
const content = Markdoc.transform(ast);
return Markdoc.renderers.react(content, React);
Check out our docs for more guidance on how to use Markdoc.
TypeScript
This is the minimal tsconfig.json
required to use Markdoc in your TypeScript project:
{
"compilerOptions": {
"moduleResolution": "node",
"target": "esnext", // works with es2015 or greater
"esModuleInterop": true
}
}
React
If you are using React, install Markdoc with:
npm install @markdoc/markdoc react @types/react
Contributing
Contributions and feedback are welcome and encouraged. Check out our contributing guidelines on how to do so.
Development
- Run
npm install
- Run
npm run build
- Run the tests using
npm test
Code of conduct
This project has adopted the Stripe Code of conduct.
License
This project uses the MIT license.
Credits
Special shout out to:
- @marcioAlmada for providing us with the @markdoc GitHub org.
- @koomen for gifting us https://markdoc.dev.
Top Related Projects
Vite & Vue powered static site generator.
The web framework for content-driven websites. ⭐️ Star to support our work!
A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
The best React-based framework with performance, scalability and security built in.
The world’s fastest framework for building websites.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot