Web Front-end
Vue.js
One article to quickly teach you how to build a blog using VuePress + Github Pages (practical)One article to quickly teach you how to build a blog using VuePress + Github Pages (practical)
This article will share with you a VuePress practical experience. Through this article, I will teach you how to quickly build a blog using VuePress Github Pages. I hope it will be helpful to everyone.

Recently completed the translation of Hanbook, the latest official TypeScript document. There are fourteen articles in total. It can be called one of the best TypeScript4 introductory tutorials in China. In order to make it easier for everyone to read, I used VuePress Github Pages to build a blog. The blog effect is as follows:


0. VuePress
VuePress Needless to say, the static website generator based on Vue has a simple style and relatively simple configuration. The reason why I don’t use VitePress is because I want to use an existing theme, and VitePress is not compatible with the current VuePress ecosystem. As for why I don’t choose VuePress@next, considering that it is still in Beta stage, wait until it stabilizes before starting the migration. [Related recommendations: "vue.js Tutorial"]
1. Local build
Quick startSame as VuePress official website:
1. Create and enter a new directory
// 文件名自定义 mkdir vuepress-starter && cd vuepress-starter
2. Use your favorite package manager to initialize
yarn init # npm init
3. Install VuePress as a local dependency
yarn add -D vuepress # npm install -D vuepress
4 , create your first document, VuePress will use docs as the document root directory, so this README.md is equivalent to the homepage:
mkdir docs && echo '# Hello VuePress' > docs/README.md
5. Add some scripts
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}## in package.json #6. Start the server locally yarn docs:dev # npm run docs:devVuePress will start a hot-reloaded development server at
http://localhost:8080 (opens new window).
2. Basic configurationCreate a.vuepress directory in the document directory, where all VuePress related files will be placed. At this time, your project structure may look like this:
. ├─ docs │ ├─ README.md │ └─ .vuepress │ └─ config.js └─ package.jsonAdd
config.js under the .vuepress folder to configure the title and description of the website to facilitate SEO:
module.exports = {
title: 'TypeScript4 文档',
description: 'TypeScript4 最新官方文档翻译'
}The interface at this time is similar to:

config.js:
module.exports = {
title: '...',
description: '...',
themeConfig: {
nav: [
{ text: '首页', link: '/' },
{
text: '冴羽的 JavaScript 博客',
items: [
{ text: 'Github', link: 'https://github.com/mqyqingfeng' },
{ text: '掘金', link: 'https://juejin.cn/user/712139234359182/posts' }
]
}
]
}
}The effect is as follows:

For more configuration, please refer to the VuePress navigation bar:https://vuepress.vuejs.org/zh/theme/default-theme-config.html#Navigation bar4. Add sidebar Now we add some md documents. The current document directory is as follows:
. ├─ docs │ ├─ README.md │ └─ .vuepress │ └─ config.js | └─ handbook | └─ ConditionalTypes.md | └─ Generics.md └─ package.jsonWe configure it in
config.js as follows:
module.exports = {
themeConfig: {
nav: [...],
sidebar: [
{
title: '欢迎学习',
path: '/',
collapsable: false, // 不折叠
children: [
{ title: "学前必读", path: "/" }
]
},
{
title: "基础学习",
path: '/handbook/ConditionalTypes',
collapsable: false, // 不折叠
children: [
{ title: "条件类型", path: "/handbook/ConditionalTypes" },
{ title: "泛型", path: "/handbook/Generics" }
],
}
]
}
}The corresponding effect is as follows:

npm install vuepress-theme-reco --save-dev # or yarn add vuepress-theme-recoThen reference the theme in
config.js:
module.exports = {
// ...
theme: 'reco'
// ...
} Refresh the page and we will find some details Changes, such as loading animation during loading, and support for switching to dark mode:

Conditional Types actually appears twice. This is because this topic automatically extracts the first headline as the title of this article. We can add it to the md of each article. Add some information modifications to the file:
--- title: 条件类型 author: 冴羽 date: '2021-12-12' ---The effect of the article at this time is as follows:

但如果你不想要标题、作者、时间这些信息呢,我们可以在样式里隐藏,这个稍后会讲到。
7. 设置语言
注意,上图的文章时间,我们写入的格式为 2021-12-12 ,但是显示的是 12/12/2021,这是因为 VuePress 默认的 lang 为 en-US,我们修改一下 config.js:
module.exports = {
// ...
locales: {
'/': {
lang: 'zh-CN'
}
},
// ...
}可以发现时间换了一种展示方式:

8. 开启目录结构
在原本的主题里,我们发现每篇文章的目录结构出现在左侧:

而 vuepress-theme-reco 将原有的侧边栏的中的多级标题移出,生成子侧边栏,放在了页面的右侧,如果你要全局开启,可在页面 config.js 里设置开启:
module.exports = {
//...
themeConfig: {
subSidebar: 'auto'
}
//...
}此时效果如下:

9. 修改主题颜色
VuePress 基于 Vue,所以主题色用的是 Vue 的绿色,然而 TypeScript 的官方色则是蓝色,那如何修改 VuePress 的主题色呢?
你可以创建一个 .vuepress/styles/palette.styl 文件,文件代码如下:
$accentColor = #3178c6
此时可以发现主题颜色变了:

更多的颜色修改参考 VuePress 的 palette.styl。
10. 自定义修改样式
如果你想自定义修改一些 DOM 元素的样式呢?就比如在暗黑模式下:

我们发现用作强调的文字颜色比较暗淡,在暗黑模式下看不清楚,我想改下这个文字的颜色和背景色呢?
而 VuePress 提供了一种添加额外样式的简便方法。你可以创建一个 .vuepress/styles/index.styl 文件。这是一个 Stylus 文件,但你也可以使用正常的 CSS 语法。
我们在 .vupress 文件夹下创建这个目录,然后创建 index.styl 文件,代码如下:
// 通过检查,查看元素样式声明
.dark .content__default code {
background-color: rgba(58,58,92,0.7);
color: #fff;
}此时文字就清晰了很多:

那之前我们提到的隐藏每篇文章的标题、作者、时间呢,其实也是类似的方式:
.page .page-title {
display: none;
}最后的效果如下:

11. 部署
我们的博客就算是正式的做好了,接下来我们部署到免费的 Github Pages 上。我们在 Github 上新建一个仓库,这里我取得仓库名为:learn-typescript。

对应,我们需要在 config.js 添加一个 base 路径配置:
module.exports = {
// 路径名为 "/<REPO>/"
base: '/learn-typescript/',
//...
}最终的 config.js 文件内容为:
module.exports = {
title: 'TypeScript4 文档',
description: 'TypeScript4 最新官方文档翻译',
base: '/learn-typescript/',
theme: 'reco',
locales: {
'/': {
lang: 'zh-CN'
}
},
themeConfig: {
// lastUpdated: '上次更新',
subSidebar: 'auto',
nav: [
{ text: '首页', link: '/' },
{
text: '冴羽的 JavaScript 博客',
items: [
{ text: 'Github', link: 'https://github.com/mqyqingfeng' },
{ text: '掘金', link: 'https://juejin.cn/user/712139234359182/posts' }
]
}
],
sidebar: [
{
title: '欢迎学习',
path: '/',
collapsable: false,
children: [
{ title: "学前必读", path: "/" }
]
},
{
title: "基础学习",
path: '/handbook/ConditionalTypes',
collapsable: false,
children: [
{ title: "条件类型", path: "/handbook/ConditionalTypes" },
{ title: "泛型", path: "/handbook/Generics" }
],
}
]
}
}然后我们在项目 vuepress-starter 目录下建立一个脚本文件:deploy.sh,注意修改一下对应的用户名和仓库名:
#!/usr/bin/env sh # 确保脚本抛出遇到的错误 set -e # 生成静态文件 npm run docs:build # 进入生成的文件夹 cd docs/.vuepress/dist git init git add -A git commit -m 'deploy' # 如果发布到 https://<USERNAME>.github.io/<REPO> git push -f git@github.com:mqyqingfeng/learn-typescript.git master:gh-pages cd -
然后命令行切换到 vuepress-starter 目录下,执行 sh deploy.sh,就会开始构建,然后提交到远程仓库,注意这里提交到了 gh-pages 分支,我们查看下对应仓库分支的代码:

我们可以在仓库的 Settings -> Pages 中看到最后的地址:

Like the last address I generated is https://mqyqingfeng.github.io/learn-typescript/
At this point, we are done Deployment of VuePress and Github Pages.
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of One article to quickly teach you how to build a blog using VuePress + Github Pages (practical). For more information, please follow other related articles on the PHP Chinese website!
Understanding Vue.js: Primarily a Frontend FrameworkApr 17, 2025 am 12:20 AMVue.js is a progressive JavaScript framework released by You Yuxi in 2014 to build a user interface. Its core advantages include: 1. Responsive data binding, automatic update view of data changes; 2. Component development, the UI can be split into independent and reusable components.
Netflix's Frontend: Examples and Applications of React (or Vue)Apr 16, 2025 am 12:08 AMNetflix uses React as its front-end framework. 1) React's componentized development model and strong ecosystem are the main reasons why Netflix chose it. 2) Through componentization, Netflix splits complex interfaces into manageable chunks such as video players, recommendation lists and user comments. 3) React's virtual DOM and component life cycle optimizes rendering efficiency and user interaction management.
The Frontend Landscape: How Netflix Approached its ChoicesApr 15, 2025 am 12:13 AMNetflix's choice in front-end technology mainly focuses on three aspects: performance optimization, scalability and user experience. 1. Performance optimization: Netflix chose React as the main framework and developed tools such as SpeedCurve and Boomerang to monitor and optimize the user experience. 2. Scalability: They adopt a micro front-end architecture, splitting applications into independent modules, improving development efficiency and system scalability. 3. User experience: Netflix uses the Material-UI component library to continuously optimize the interface through A/B testing and user feedback to ensure consistency and aesthetics.
React vs. Vue: Which Framework Does Netflix Use?Apr 14, 2025 am 12:19 AMNetflixusesacustomframeworkcalled"Gibbon"builtonReact,notReactorVuedirectly.1)TeamExperience:Choosebasedonfamiliarity.2)ProjectComplexity:Vueforsimplerprojects,Reactforcomplexones.3)CustomizationNeeds:Reactoffersmoreflexibility.4)Ecosystema
The Choice of Frameworks: What Drives Netflix's Decisions?Apr 13, 2025 am 12:05 AMNetflix mainly considers performance, scalability, development efficiency, ecosystem, technical debt and maintenance costs in framework selection. 1. Performance and scalability: Java and SpringBoot are selected to efficiently process massive data and high concurrent requests. 2. Development efficiency and ecosystem: Use React to improve front-end development efficiency and utilize its rich ecosystem. 3. Technical debt and maintenance costs: Choose Node.js to build microservices to reduce maintenance costs and technical debt.
React, Vue, and the Future of Netflix's FrontendApr 12, 2025 am 12:12 AMNetflix mainly uses React as the front-end framework, supplemented by Vue for specific functions. 1) React's componentization and virtual DOM improve the performance and development efficiency of Netflix applications. 2) Vue is used in Netflix's internal tools and small projects, and its flexibility and ease of use are key.
Vue.js in the Frontend: Real-World Applications and ExamplesApr 11, 2025 am 12:12 AMVue.js is a progressive JavaScript framework suitable for building complex user interfaces. 1) Its core concepts include responsive data, componentization and virtual DOM. 2) In practical applications, it can be demonstrated by building Todo applications and integrating VueRouter. 3) When debugging, it is recommended to use VueDevtools and console.log. 4) Performance optimization can be achieved through v-if/v-show, list rendering optimization, asynchronous loading of components, etc.
Vue.js and React: Understanding the Key DifferencesApr 10, 2025 am 09:26 AMVue.js is suitable for small to medium-sized projects, while React is more suitable for large and complex applications. 1. Vue.js' responsive system automatically updates the DOM through dependency tracking, making it easy to manage data changes. 2.React adopts a one-way data flow, and data flows from the parent component to the child component, providing a clear data flow and an easy-to-debug structure.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools






