Based on the static blog generation of vitepress, build a blog of your own in five minutes
- Simplified configuration, out of the box
- Initialize the scaffold
- Extend markdown to support more syntax
- Footnotes
- Superscript and subscript
- Todo List
- Katex math formula
- img lazy loading optimization
- UML
- Articles
- Top
- Cover image
- Creation time
- Automatically intercept article abstracts
- Folder Mapping Tab
- Article label classification
- Article Timeline Archive
- Dark Light Theme
- Mobile support
---
top: true
coverImg: xxxx
tags:
- Essay
---
- default Preview
At present, only one default theme has been developed, and friends are welcome to contribute their own themes
It is recommended to use pnpm
mkdir blog && cd blog # Create an empty directory and go into it
# with npm
npm i vitepress vitepress-blog # Install the dependencies
npm i vitepress-blog -g # Install command line tools
# or with pnpm
pnpm add vitepress vitepress-blog
Run vitepress-blog init ./
in the terminal, and initialize blog-related configuration files according to the prompts.
vitepress-blog init ./
# And answer the following questions in CLI, for instance:
# ? What's the name of your project > myBlog
# ? What's your github name > yue1123
# Pick blog theme > defaultBlogTheme
# Pick language of configuration file > TypeScript
# ? Would you like to add start,build,preview commands to 'package.json' > yes
After the initialization is successful, you can run the blog
# run locally
pnpm run blog:dev
# Pack
pnpm run blog:build
├── blog
│ └── site
│ │ └── posts # blog storage folder, support subfolders
│ │ │ └── hello-vitepress-blog.md # sample article
│ │ ├── public # Pictures and other public resource folders
│ └── .vitepress
│ │ ├── theme
│ │ │ └── index.ts
│ │ └── config.mts
└── package.json
##Note
- It is recommended to read the vitepress document for in-depth use
- If you use github-action deployment, be sure to set checkout
fetch-depth
to zero to ensure that the article creation time is correct
- name: Check out repo's default branch
uses: actions/checkout@v3
with:
ref: "master"
fetch-depth: 0
- Set the name of the github warehouse to
username.github.io
(so that you can get a domain name pointing to the current warehouse) - Configure git pages: warehouse Settings > Pages > select
gh-pages
branch root directory > save