This repo is an easy to use starting point for your blogs using Next.js, Tailwind CSS and MDX to create a blog with tags and categories.
- Static MDX Development: Using static MDX files makes it easy to start your blog without connecting to third party API's, CDN's or a database. This approach is ideal for simple applications.
- Rich Metadata with Front Matter: Use the front matter in your MDX files to store essential post metadata. From tags and categories to author information and descriptions, it can be easily parsed using the gray-matter package.
- Stylish Typography with Tailwind CSS: Apply some default styling to your blog using the Tailwind CSS Typography plugin, making it look like great instantly.
- Code Highlighting: Use the Rehype Highlight plugin to add syntax highlighting to your code snippets in your desired style.
- SEO Optimized: Implement some Next.js SEO best practices to make your blog more discoverable.
Combining these elements creates a great starting point for your blog that's easy to customize and reuse in all your projects.
- Clone the repository
- Run
npm install
- Run
npm run dev
- Open http://localhost:3000 in your browser
Or use the VSCode debugger to run the development server, configured in the .vscode/launch.json
file.
- Copy the entire
app/blog
folder to your project - Install all packeges
npm install gray-matter @next/mdx @mdx-js/loader @mdx-js/react @types/mdx next-mdx-remote rehype-highlight remark-gfm npm install -D @tailwindcss/typography
- Copy the mdx-components.tsx file to the root of your project (same level as the
app
folder) - Edit the next.config.js file to look like this:
import createMDX from "@next/mdx"; /** @type {import('next').NextConfig} */ const nextConfig = { pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"], }; const withMDX = createMDX({ // Add markdown plugins here, as desired }); // Merge MDX config with Next.js config export default withMDX(nextConfig);
- Add the Tailwind CSS Typography plugin to your
tailwind.config.js
file/** @type {import('tailwindcss').Config} */ module.exports = { theme: { // ... }, plugins: [ require('@tailwindcss/typography'), // ... ], }
- Copy the
public/blog
folder to your project. This is where all the images for your blog posts will be stored. - Ready to go!
Important: Make sure the slug in the MDX file is the same as the file name!