运行环境win10 node.js
一、 安装hexo
npm install hexo-cli g
# 初始化博客文件夹
hexo init blog
# 切换到该路径
cd blog
# 安装hexo的扩展插件
npm install
# 安装其它插件
npm install hexo-server --save
npm install hexo-admin --save
npm install hexo-generator-archive --save
npm install hexo-generator-feed --save
npm install hexo-generator-search --save
npm install hexo-generator-tag --save
npm install hexo-deployer-git --save
npm install hexo-generator-sitemap --save
第一次使用hexo,在本地创建服务器使用。
# 生成静态页面
hexo generate
# 开启本地服务器
hexo s
打开浏览器,地址栏中输入:http://localhost:4000/,应该可以看见刚刚创建的博客了
二、hexo管理
# 清空静态页面
hexo clean
# 生成静态页面
hexo generate
# 部署
hexo deploy
三、hexo命令缩写
hexo g = hexo generate
hexo c = hexo clean
hexo s = hexo server
hexo d = hexo deploy
四、其他及问题
- 端口占用,换个端口就好了。执行命令
hexo s -p 5000
,并在浏览器地址栏输入http://localhost:5000,回车访问。 - 出现下图错误,
- 1.cmd进入博客当前文件夹路径
-
2.执行 npm install
-
3.执行 hexo server
-
添加next主题后,home等无法变中文。在修改主目录_config.yui中的language: zh-Hans,其中zh-Hans要看一下,你选的主题下的language目录下,简体中文是什么名字,有的是zh-cn.
-
hexo主题的修改参看:http://theme-next.iissnan.com/getting-started.html
-
Hexo之next主题设置首页不显示全文(只显示预览)
- 进入hexo博客项目的themes/next目录
- 用文本编辑器打开_config.yml文件
- 搜索"auto_excerpt",找到如下部分:
- 把enable改为对应的false改为true,然后
hexo d -g
,再进主页,问题就解决了! -
# Automatically Excerpt. Not recommand. # Please use <!-- more --> in the post to control excerpt accurately. auto_excerpt: enable: false length: 150
npm install安装出错.
-
npm install --registry=https://registry.npm.taobao.org --loglevel=silly
-
npm cache clean --force
-
-
hexo之next主题添加分类.
-
hexo new page categories
-
编辑新建界面,将页面类型设置为categories:type: "categories"
-
在menu中添加链接,此时需要编辑主题的
_config.yml
-
在markdown文件中添加分类:categories: 电影评论
-
-
为博客添加图
-
首先确认 _config.yml 中有 post_asset_folder:true 。
-
将图片放到与文件名同名的目录中
-
在markdown文件中,只能用文件名,不要路径.
-