1. 安装Notejs |
1. download Notejs Note.js安装完毕之后默认是在以下目录 C:Program Files odejs Node module 默认目录是在 C:Program Files odejs ode_modules 用户的一部分 C:Users angrAppDataRoaming pm ode_modules 例如hexo-cli C:Users angrAppDataRoaming pm ode_moduleshexo-cli C:Users angrAppDataRoaming pm ode_moduleshexo-cliin C:Users angrAppDataRoaming pm ode_moduleshexo-clilib |
2、安装git | https://git-scm.com/download/win
配置环境变量 1、从Git官网下载windows版本的git:http://git-scm.com/downloads 2、一般使用默认设置即可:一路next,git安装完毕! 3、但是如果这时你打开windows的cmd,在里面打git命令会提示“不是内部或外部命令,也不是可运行的程序”, 想要直接在windows的cmd里使用git命令要多加如下两步 3.1、找到git安装路径中bin的位置,如:C:Program FilesGitin 找到git安装路径中git-core的位置,如:C:Program FilesGitmingw64libexecgit-core; 注:"D:Program FilesGit"是安装路径,可能与你的安装路径不一样,要按照你自己的路径替换"D:Program FilesGit" 3.2、右键“计算机”->“属性”->“高级系统设置”->“环境变量”->在下方的“系统变量”中找到“path”->选中“path”并选择“编辑”->将3.1种找到的bin和git-core路径复制到其中->保存并退出 注:“path”中,每个路径之间要以英文输入状态下的分号——“;”作为间隔 |
3、安装hexo | 安装hexo的命令:
npm install -g hexo-cli |
4、生成blog | 从现在开始,我们就可以用hexo来生成一个博客了。
首先新建一个文件夹,位置随意,然后 cd 到这个文件夹下,运行命令: hexo init hexo会将这个文件夹初始化成一个博客专用文件夹,生成过程稍微要点时间,耐心等待。 初始化完成后,会有一个默认主题以及一个hello-word的默认文章。所以我们可以先生成博客来看一下效果,运行命令: hexo generate //可以简写成 hexo g 然后hexo会开始生成博客,生成结束后,会多出一个public的文件夹,这个文件夹就是hexo生成的一个完整的静态网站,也就是我们的博客。 网站生成好了,我们要浏览它,所以要开启一下服务器,运行命令: hexo server //可以简写成 hexo s 然后打开浏览器,输入 localhost:4000 就可以浏览我们的博客了。 |
5、远程部署(git) | npm install hexo-deployer-git --save
安装好hexo-deployer-git后,修改博客目录配置文件中的deploy字段: deploy: type: git repo: git仓库项目地址 branch: 分支 message: 自定义提交说明,这个字段可以没有 如果git仓库是ssh,则需要生成.ssh,这是git的操作,不做详述。 |
6、安装admin插件 | 1、在Hexo网站目录下,安装 Hexo Admin 插件
npm install --save hexo-admin
或# install hexo-myadmin (该插件比hexo-admin要强大的多) npm install hexo-myadmin --save { you can add a few config variables to your hexo
The } 2、启动本地服务器并打开管理界面,即可使用 hexo server -d http://localhost:4000/admin/#
优化: node_moduleshexo-adminwwwloginindex.html将Username, Password两个字段去掉。 node_moduleshexo-adminwwwundle.css ... .editor_title { font-size:34px; -> font-size: 16px } |
7、修改标题 | _config.yml |
8、其它定制 | 1)修改主页条目:
themeslandscape\_config.yml 2)修改menu: 主页: / 事务: /archives 3)修改Banner themeslandscapesourcecssimagesanner.jpg 4)修改版权 themeslandscapelayout\_partialfoot.ejs 导航 边栏 </div> </div> <% } %> 底栏 banner |
9、增加搜索 | npm install hexo-generator-searchdb --save
修改 站点配置 文件
修改 主题配置文件
<script type="text/javascript" src="../../../../js/jquery.min.js"></script> ~~~ |
10、运行 |
$ hexo server -p 选项,指定服务器端口,默认为 4000 -i 选项,指定服务器 IP 地址,默认为 0.0.0.0 -s 选项,静态模式 ,仅提供 public 文件夹中的文件并禁用文件监视 自动脚本 (*.vbs): set ws = createobject("wscript.shell") (*.bat): c: |
11、NGINX 方向代理 |
#add server { #charset koi8-r; #access_log logs/host.access.log main; location / { # add page indirecting ... } |
12. 检索页面 |
<script type="text/javascript" src="../../../../js/jquery.min.js"></script> |