配置环境
安装node.js
- 登陆 node.js 官网,根据对应的操作系统,选择相应的版本
- 安装node.js
- 在命令行里, 运行
node -v, 若有版本信息,则安装成功, 反之亦然。
安装hexo
- 运行
npm install -g hexo-cli, 安装hexo - 运行
hexo -v, 若有版本信息,则安装成功, 反之亦然。 - 运行
npm install hexo-deployer-git --save, 安装github上传包
安装git
- 登陆git下载网址, 根据对应的操作系统,选择相应的版本
- 安装git
- 在命令行里, 运行
git --version, 若有版本信息,则安装成功, 反之亦然。
github
- 注册账号
- 建立一个Repositories,用于存放博客静态文件,名称格式最好为:
用户名.github.io - 设置远程,
git remote add remoteName url, url 为 Repositories 选项setting中Github Pages提示的url - 查看远程设置,
git remote -v - 重新配置,
git remote set-url remoteName url
初次搭建博客
创建本地文件
- hexo init [blogsName]
- cd yourpath/blogsName
- 启动本地服务器,hexo s or hexo server
- 在浏览器中输入,localhost:4000, 查看有无界面, 有则成功
配置_config.yml
- 修改
site字段,配置language,author,title,description, 支持的语言在language option - 修改
url字段,配置url和 根目录root - 修改
Extension字段,配置theme,默认是landscape - 修改
deploy字段,配置type,repository,branch
示例如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27# Site
title: Hexo
subtitle:
description: keep hungry and practice more
keywords:
author: Jun Fu
language: en
timezone:
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://github.com/SunshineJunFu/JunFu.github.io
root: /JunFu.github.io/
permalink: :year/:month/:day/:title/
permalink_defaults:
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: https://github.com/SunshineJunFu/JunFu.github.io
branch: master
上传至github
- 运行
hexo g -d - 点击对应Repositories 选项
setting中Github Pages提示的url,查看效果
hexo 命令
hexo init blogsName, 创建文件夹hexo generate,可简写为hexo g, 生成网页静态文件hexo server,可简写为hexo s, 创建本地服务器hexo deploy,可简写为hexo d, 上传至githubhexo clean, 清理缓存hexo new post Name, 创建博客hexo new page Name, 创建网页
更多信息,可以参考hexo writing