A simple blog template built with Next.js that allows you to generate static blog pages from Markdown files.
daisyUI
theme. You can also create your own theme.Check out the live demo: https://campanula-demo.vercel.app/
Make sure you have the following software installed:
Clone the repository:
git clone https://github.com/sakurabird/Campanula.git
cd Campanula
Install the dependencies:
npm install
data/siteMetadata.js
file.app
folder. For detailed instructions, please refer to the official website: Metadata Files: favicon, icon, and apple-icon | Next.jsdata/headerNavLinks.ts
to set the navigation items for the header.By default, there are two static pages, Home
and About
, and all others are related to blog posts.
Please also check out the following article on routing:
Routing and blog navigation
Please also check out the following article on asset files:
The location of asset files in Campanula
The Home
page is the default page that is displayed when you visit a website created using Campanula
.
The configuration method for the Home
page has been summarized in another article.
Please take a look at:
How to create a Home page in Campanula
The About
page is a static page intended for self-introductions and the like.
It can be accessed with the path /about
.
The configuration method for the About
page has been summarized in another article.
Please take a look at:
How to create a About page in Campanula
Create new blog posts by adding Markdown files to the data/blog
directory. Please use the extension mdx. ex: title-of-your-post.mdx
. The filenames of MDX files will be used as part of the URL. To avoid compatibility and encoding issues in the URL, it is recommended to use characters from the ASCII character set.
Add necessary frontmatter to each Markdown file, including title
, date
, and any other relevant information.
Each blog post must have a front matter.
Currently 9 fields are supported.
title: (required)
date: (required)
category: (required)
tags: (optional)
subtitle: (optional)
lastmod: (optional)
draft: (required)
metadescription: (optional)
image: (optional, if none provided defaults to `ogImage` in siteMetadata config)
Here's an example of a post's frontmatter:
---
title: "Cats: The Adorable Feline Friends"
date: "2022-02-22"
category: "Animal"
tags: ["cat"]
subtitle: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris hendrerit rhoncus risus, nec rutrum sapien sodales sit amet."
lastmod: "2023-04-23"
draft: false
metadescription: "Cats are cute, cuddly, and make great companions."
image: "/images/blog/cat.jpg"
---
First, run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the result.
To deploy your blog to the production server, run the following command:
npm run build
The easiest way to deploy Next.js to production is to use the Vercel platform developed by the creators of Next.js.
TODO
Feel free to customize the template to suit your needs. You can modify the layout, styles, and even add new features.
You can customize it with daisyUI
theme. You can also create your own theme.
Thank you for the reference to quality information. Mr. timlrx's code was fantastic, and I have adopted many aspects of it in this project. Thank you so much for your contributions.
I used the materials from the following websites. Thank you very much!
theme
variable in siteMetadata.js, the screen will automatically switch to the light mode when you refresh the page after building. If you want to display the dark mode, please press the theme toggle button in the header.npm run clean
. This command will not remove the source code or assets, but it will clean up generated files.This project is licensed under the MIT License - see the LICENSE file for details.