安装前准备
Windows上安装Node.JS
- F:\node-v8.11.1-win-x64安装根目录下新建node_global和node_cache两个目录,
- F:\node-v8.11.1-win-x64下的整个node_modules目录剪切到新建的node_global目录下
- 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 | npm config set registry http://registry.npm.taobao.org |
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 | # Hexo Configuration |
自定义配置文件
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
先安装一个插件
npm install hexo-deployer-git –save配置_config.yml中有关deploy的部分
deploy:
type: git
repository: git@github.com:yida-lxw/yida-lxw.github.io.git
branch: master命令行下输入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
10title: 博客标题
layout: 可选值post,page,draft
date: 博客的发布日期
comments: 是否开启博客评论功能
post_catalog: 是否在博客右侧显示博客大纲目录
tags: 设置博客的标签
categories: 设置博客的分类
keywords: 设置博客的关键字,用于SEO
permalink: 自定义博客的访问URL
description: 博客的描述信息,可以不填