前言
GitPages+Hexo搭建個人博客這篇文章已經(jīng)介紹了GitHubPages創(chuàng)建博客項(xiàng)目和Hexo的安裝,下面開始介紹Hexo基本配置。
目錄
- 配置_config.yml文件
- Hexo常用命令
- Hexo插件安裝
配置_config.yml文件
- 站點(diǎn)配置(重要)
# Site
title: WenBo丨星空灬 //網(wǎng)站標(biāo)題
subtitle: To strive, to seek, to find, and not to yield. //網(wǎng)站副標(biāo)題
description: To strive, to seek, to find, and not to yield. //網(wǎng)站描述
author: WenBo //您的名字
language: zh-Hans //網(wǎng)站使用的語言 簡體中文 zh-Hans
timezone: //網(wǎng)站時區(qū)。Hexo 默認(rèn)使用您電腦的時區(qū)
- URL配置
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://blogwenbo.com/ //網(wǎng)址
root: / //網(wǎng)站根目錄
permalink: :year/:month/:day/:title/ //| 文章的 [永久鏈接](https://hexo.io/zh-cn/docs/permalinks.html) 格式 | `:year/:month/:day/:title/` |
permalink_defaults: //永久鏈接中各部分的默認(rèn)值
- 目錄配置
# Directory
source_dir: source //資源文件夾,這個文件夾用來存放內(nèi)容。默認(rèn)值:source
public_dir: public //公共文件夾,這個文件夾用于存放生成的站點(diǎn)文件。默認(rèn)值:public
tag_dir: tags //標(biāo)簽文件夾 默認(rèn)值:tags
archive_dir: archives //歸檔文件夾 默認(rèn)值:archives
category_dir: categories //分類文件夾 默認(rèn)值:categories
code_dir: downloads/code //Include code 文件夾 默認(rèn)值:downloads/code
i18n_dir: :lang //國際化(i18n)文件夾 默認(rèn)值::lang
skip_render: README.md //跳過指定文件的渲染,您可使用 [glob 表達(dá)式](https://github.com/isaacs/node-glob)來匹配路徑。
- Git部署配置(重要)
deploy:
type: git //填git
repo: git@github.com:wenmobo/wenmobo.github.io.git //SSH地址
branch: master //分支
- 配置README.md
找到skip_render,并添加README.md
skip_render: README.md
- 切換主題
例如:切換成NexT主題,在hexo根文件加下,編輯**_config.yml**文件
theme: next
//配置之后,執(zhí)行以下命令清除一下緩存
hexo clean
Hexo命令
- 初始化文件夾網(wǎng)站(重要)
//Hexo 默認(rèn)在目前的文件夾建立網(wǎng)站
hexo init
//指定文件夾
hexo init [folder]
- 新建一篇文章(重要)
hexo new "my blog"
- 生成靜態(tài)文件(重要)
hexo generate
//簡寫
hexo g
選項(xiàng) 描述
-d, --deploy 文件生成后立即部署網(wǎng)站
-w, --watch 監(jiān)視文件變動
- 發(fā)表草稿
hexo publish [layout] <filename>
- 啟動服務(wù)器。默認(rèn)情況下,訪問網(wǎng)址為: http://localhost:4000/(重要)
hexo server
//簡寫
hexo s
選項(xiàng) 描述
-p, --port 重設(shè)端口
-s, --static 只使用靜態(tài)文件
-l, --log 啟動日記記錄,使用覆蓋記錄格式
- 部署網(wǎng)站(重要)
hexo deploy
//簡寫
hexo d
- 查看hexo版本
hexo version
//簡寫
hexo v
- 新建頁面(重要)
//比如說新建標(biāo)簽頁面,執(zhí)行命令之后會在根目錄source文件夾下創(chuàng)建tags文件夾
hexo new page "tags"
Hexo插件安裝
- Hexo安裝Git插件(重要)
npm install --save hexo-deployer-git
總結(jié)
參看了一些博客,配置好上面這些內(nèi)容,和熟悉上面這些常用命令,自己也能用Hexo創(chuàng)建博客了,自己也是才開始搭建自己的博客,有些整理的還不是很完善,以后會繼續(xù)補(bǔ)充。下面一片文章是講解如何安裝使用Next主題的博客:Hexo-NexT配置超炫網(wǎng)頁效果。有興趣的朋友,可以來看看吧。