Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Starter code for creating a static blog using Next.js and MDX. A service worker for offline reading is set up, and the blog has Perfect Lighthouse scores.
Next.js MDX Blog Kit is a developer-focused boilerplate for creating a static blog with Next.js and MDX, built to achieve perfect Lighthouse scores out of the box. It gives you a complete blogging system where you only have to write posts and style the blog to make it your own.
Next.js MDX Blog Kit is an open-source starter repository from GitHub user lorenseanstewart that provides a complete blogging system on the Next.js framework. It takes markdown and MDX files as input—which can include embedded React components—and produces a statically deployable blog with SEO metadata, tag search, and offline support. The kit is designed so that the only two required tasks are writing posts and styling the blog.
-t for template type, -m for MDX, and -f for file name./search/?q=tagName lets readers filter by tag.hideProgressBar meta property.react-syntax-highlighter for JavaScript syntax highlighting, with example components in the code-snippets folder.next-optimized-images to optimize image loading.Next.js developers who want a pre-built blog instead of starting from scratch will find the CLI and blog engine save setup time. Technical content creators who write in markdown and need SEO-friendly publications can publish posts without touching underlying code. Developers exploring MDX and React component composition in markdown can use the included examples as a learning reference. Teams looking to ship a company blog with offline support and tag search can deploy it quickly to Now.
The kit includes a blog engine that extracts the meta object from each page and post component, constructs additional properties, and builds a sorted post list. The utils/page-list.js and utils/post-list.js files use the Babel Preval plugin to read filenames from the pages directories. Global configuration lives in /config/config.yml, where you set author, site name, navigation links, and brand colors. To create content, run blog -t post after installing the CLI with npm link, and the CLI generates the proper meta data. The kit also includes a Service Worker file (my-worker.js) with comments on caching behavior.
Use the CLI with blog -t post to generate a new post file. The -f flag lets you name the file; if omitted, the CLI creates a randomized name that you should rename. You can also create MDX posts with the -m flag.
Each page or post must export a meta object with fields including title, tags, layout, publishDate, and seoDescription. Optional fields like hideProgressBar and exclude control the reading progress bar and whether the post appears on the blog list.
Import the image at the top of your MDX file, e.g., import imageUrl from "../../public/static/images/mountains.jpg";, then use it with a normal img tag and the imported path as src.
The service worker caches every page for desktop users, so the entire blog is available offline after first visit. For mobile users, only pages that have been visited are cached. The developer notes these observations are informal and may vary by browser and device.
Add font files to /static/fonts and define @font-face rules in /styles/index.js. The included font is Abril Fatface, and the project uses font-display: auto; to balance performance and loading.