Hexo安装

安装前准备

Windows上安装Node.JS

  1. F:\node-v8.11.1-win-x64安装根目录下新建node_global和node_cache两个目录,
  2. F:\node-v8.11.1-win-x64下的整个node_modules目录剪切到新建的node_global目录下
  3. F:\node-v8.11.1-win-x64安装根目录下的node.exe、npm、npm.cmd、npx、npx.cmd文件剪切到F:\node-v8.11.1-win-x64\node_global目录下

配置系统环境变量

NODEJS_HOME
F:\node-v8.11.1-win-x64\node_global

PATH末尾追加;%NODEJS_HOME%

NODE_PATH
F:\node-v8.11.1-win-x64\node_global\node_modules

安装express模块:

npm install express -g

可以手动指定从哪个镜像服务器下载资源:

npm install -gd express –registry=http://registry.npm.taobao.org

为了避免每次都需要设置–registry,可以进行如下配置,从而一劳永逸

1
2
3
4
5
npm config set registry http://registry.npm.taobao.org

npm config set prefix "F:\node-v8.11.1-win-x64\node_global"

npm config set cache "F:\node-v8.11.1-win-x64\node_cache"

Hexo安装

npm install -g hexo-cli

npm install hexo-server

创建hexo文件夹

G:/hexo

\$ hexo init G:/hexo
\$ cd G:/hexo
\$ npm install

配置_config.yml:

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: yida's blog
subtitle:
description:
keywords:
author: Lanxiaowei
language: zh
timezone: Asia/Shanghai

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://imyida.com
root: /
permalink: :title.html
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
- README.md
- README.cn.md

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 10
order_by: -date

# Category & Tag
default_category: Default
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
#hiker clean-blog landscape
theme: hiker

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@github.com:yida-lxw/yida-lxw.github.io.git
branch: master

自定义配置文件

hexo –config custom.yml,custom2.json

生成

$ hexo g

启动服务

$ hexo s

修改博客主题:

hexo主题下载网址:https://hexo.io/themes/
将下载好的主题复制到G:\hexo\themes目录下,然后修改_config.yml中的theme: landscape改为theme: hiker
hexo clean
hexo g
hexo s

将博客上传到Github

  1. 先安装一个插件
    npm install hexo-deployer-git –save

  2. 配置_config.yml中有关deploy的部分
    deploy:
    type: git
    repository: git@github.com:yida-lxw/yida-lxw.github.io.git
    branch: master

  3. 命令行下输入hexo d
    中途可能会报错,Error: Host key verification failed.
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights and the repository exists.
    解决方法:添加SSHkey
    $ ssh-keygen -t rsa -C “949226420@qq.com
    将C:\Users\Administrator.ssh目录下生成的id_rsa.pub文件内容添加到Github上的SSHKey里,
    然后cd hexo目录下,将hexo目录初始化为一个github本地仓库,执行命令如下所示:
    git init
    git remote add origin git@github.com:yida-lxw/yida-lxw.github.io.git

hexo常用命令

hexo new “postName” #新建文章
hexo new page “pageName” #新建页面
hexo generate #生成静态页面至public目录
hexo publish #先发布到本地,便于本地后续预览
hexo server #开启预览访问端口(默认端口4000,’ctrl + c’关闭server)
hexo deploy #部署到GitHub
hexo help # 查看帮助
hexo version #查看Hexo的版本

缩写

hexo n == hexo new
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy

生成并本地预览

hexo s -g

生成并上传

hexo d -g

如何让博文列表不显示全部内容

在合适的位置加上<!--more-->即可

hexo如何删除某篇博客

1.首先进入到source/_post 文件夹,删除该博客的md文件
2.重新生成并上传至github即执行hexo d -g

博客头部支持的配置属性说明

title: Hexo安装
layout: post
date: 2018-06-17 22:43:16
comments: true
post_catalog: true
tags:
- Hexo
categories:
- Hexo
keywords: Hexo
permalink: install-hexo
description:

1
2
3
4
5
6
7
8
9
10
title: 博客标题
layout: 可选值post,page,draft
date: 博客的发布日期
comments: 是否开启博客评论功能
post_catalog: 是否在博客右侧显示博客大纲目录
tags: 设置博客的标签
categories: 设置博客的分类
keywords: 设置博客的关键字,用于SEO
permalink: 自定义博客的访问URL
description: 博客的描述信息,可以不填

Copyright © 2018 - 2018 Lanxiaowei All Rights Reserved.

UV : | PV :