Hexo & NexT 搭建个人网站

1. 搭建环境(2020-2-6)

2. 安装 Hexo

1
$ npm install hexo-cli -g

3. 创建 hexo 工程

新建工程

1
$ hexo init [folder]

新建post

1
$ hexo new [layout] <title>

编译工程

1
$ hexo generate

本地服务

1
$ hexo server

部署

1
$ hexo deploy

其他常用命令

1
2
3
$ hexo clean 
$ hexo g && hexo s
$ hexo clean && hexo g && hexo d

4. 一键发布到 Github 和 Coding

4.1 安装 hexo-deployer-git.

4.2 配置 hexo/_config.yml, 添加代码:

1
2
3
4
5
6
7
deploy:
repo:
# 下面两种写法都支持
github: https://github.com/user/project.git,branch
coding:
url: https://git.coding.com/user/project.git
branch: branch_name

4.3 部署使用 hexo clean && hexo g && hexo d.

5. 配置工程hexo/_config.yml

1
2
3
4
5
6
7
8
9
10
title: 
subtitle:
author:
description: #描述 SEO
language: zh-CN
timezone: #建议不填

skip_render:
- README.md
- CNAME

6. 安装主题 NexT

6.1 NexT 主题下载

1
2
$ cd hexo
$ git clone https://github.com/theme-next/hexo-theme-next themes/next

6.2 应用主题,配置hexo/_config.yml:

1
theme: next

更多主题: https://github.com/hexojs/hexo/wiki/Themes

7. 配置主题 NexT

以下配置都在 NexT 主题配置文件 next/_config.yml

7.1 选择 Scheme

1
2
3
4
#scheme: Muse
#scheme: Mist
#scheme: Pisces
scheme: Gemini

7.2 选择语言

1
language: zh-CN

7.3 配置 menu

1
2
3
4
5
6
7
8
9
menu:
home: / || home
#about: /about/ || user
#tags: /tags/ || tags
#categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
#sitemap: /sitemap.xml || sitemap
#commonweal: /404/ || heartbeat

7.4 配置 Tags 和 Categories

menu 中配置 tags 和 categories,需要自定义 page。自定义Tags

7.5 配置 Sidebar

1
2
3
4
5
6
7
8
9
10
11
# Sidebar Avatar
avatar:
# Replace the default image and set the url here.
url: /images/avatar.png
# If true, the avatar will be dispalyed in circle.
rounded: true
# If true, the avatar will be rotated with the cursor.
rotated: false

# Posts / Categories / Tags in sidebar.
site_state: true

7.6 配置 Favicon

1
2
3
4
5
6
7
favicon:
small: /images/favicon-16x16-next.png
medium: /images/favicon-32x32-next.png
apple_touch_icon: /images/apple-touch-icon-next.png
safari_pinned_tab: /images/logo.svg
android_manifest: /images/manifest.json
ms_browserconfig: /images/browserconfig.xml

7.7 配置 Back2top

1
2
3
4
5
6
back2top:
enable: true
# Back to top in sidebar.
sidebar: false
# Scroll percent label in b2t button.
scrollpercent: true

7.8 配置字体

1
2
3
4
5
6
font:
enable: true
global:
external: true
family: Menlo
size: 1.125

7.9 GitHub Banner

1
2
3
4
github_banner:
enable: true
permalink: https://github.com/yourname
title: Follow me on GitHub

7.10 阅读全文(控制首页显示位置)

<_post>.md 中添加 <!-- more --> 标签

更多主题配置: https://theme-next.org/docs/theme-settings/

作者

Dench

发布于

2020-02-06

更新于

2020-02-06

许可协议

CC BY-NC-SA 4.0

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×