一、前期准备
- 安装node,npm,通过cmd可以看出来是否安装成功
node(前端框架)
npm(随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题)
- 接下来安装cnpm 速度更块是淘宝做的国内镜像
通过输入命令行(npm install -g cnpm -registry=https://registry.npm.taobao.org)
- 安装hexo框架
执行语句完成安装 cnpm install -g hexo-cli
- 新建一个文件夹用来存放生成的blog文件
二、hexo相关操作
- 执行(hexo init),初始化hexo环境,需要较长时间
安装时会卡在npm install loadAllDepsIntoIdealTree
因为npm还是通过原有地址进行下载,需要修改成镜像地址
修改
npm config set registry https://registry.npm.taobao.org
查看
npm config get registry
看到以下说明初始化成功
- 启动(hexo s)
即可看到自己的博客
常用命令
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
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
三、发布到Github上
-
自己的github上新建一个仓库
-
安装hexo的git插件
cnpm install hexo-deployer-git --save -
修改_config.yml 文件,里面是配置信息
最后一行修改
-
命令hexo d,发布到git仓库
-
直接连接 https://zqfang666.github.io/ 进入博客
博客美化
- _config.yml 文件的信息
#博客名称
title: 我的博客
#副标题
subtitle: 一天进步一点
#简介
description: 记录生活点滴
#博客作者
author: lxq
#博客语言
language: zh-CN
#时区
timezone:
#博客地址,与申请的GitHub一致
url: http://elfwalk.github.io
root: /
#博客链接格式
permalink: :year/:month/:day/:title/
permalink_defaults:
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
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: true
tab_replace:
default_category: uncategorized
category_map:
tag_map:
#日期格式
date_format: YYYY-MM-DD
time_format: HH:mm:ss
#分页,每页文章数量
per_page: 10
pagination_dir: page
#博客主题
theme: landscape
#发布设置
deploy:
type: git
#elfwalk改为你的github用户名
repository: https://github.com/elfwalk/elfwalk.github.io.git
branch: maste
- 通过 git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia 命令,来克隆主题