整个博客框架是基于node.js的,安装node.js,Windows Installer 64-bit,一路next即可,查看是否安装成功
node -v
npm -v
Git用来将hexo的相关文件部署到Github上去,安装过程一路Next,GIt官网下载地址,查看是否安装成功
git --version
安装hexo
npm install hexo-cli -g
npm install hexo --save
hexo -v #查看是否安装成功
hexo init #初始化网站--------很慢,耐心等待!!!
npm install #自动安装需要的组件
hexo g #generate
hexo s #server 启动本地服务器
复制网址 http://localhost:4000 查看网站
其他命令
hexo n == hexo new
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy
hexo new "文章名" #新建文章
hexo new page "页面名" #新建页面
http://localhost:4000 这个界面在本地,别人并不能看到,想要别人看到,我们就必须将这些文件部署到Github上去。
建立GitHub账号,右上角加号点击New repository,Repository name下填写 yourname.github.io,public,create repository。
配置Deployment,修改 Hexo/_config.yml 文件,注意type,repo,branch冒号后都有一个空格
deploy:
type: git
repo: [email protected]:JH0lmes/JH0lmes.github.io.git
branch: master
将Hexo与github page 联系起来
在hexo文件夹右击,Git Bash Here,然后键入以下代码
1.设置Git的user name和email:(如果是第一次的话)
git config --global user.name "JH0lmes"
git config --global user.email "[email protected]"
2.生成密钥,键入以下,然后回车,然后填密码,五位及以上,填两遍,会在
C:\Users\Administrator\.ssh 文件夹中生成几个文件
ssh-keygen -t rsa -C "[email protected]" #其中id_rsa为密钥 id_rsa.pub为公钥
3.到GitHub网页,点击头像Settings,找到SSH and GPG keys,随意填一个Title,Key为
C:\Users\Administrator\.ssh\id_rsa.pub里的内容,复制进去,点击Add SSH key,输入密码
4.查看ssh是否添加成功,输入密码,如果看到Hi后面是你的用户名,就说明成功了
ssh -T [email protected]
5.部署到github,刷新 JH0lmes.github.io 就可以看到自己的博客了
hexo g
hexo d
完善建好的博客
hexo文件夹下,
public #源码文件夹
themes #主题文件夹
_config.yml #站点配置文件
themes\landscape\_config.yml #主题配置文件
source\_posts\hello-world.md #键入hexo new 'filename'生成.md文件,可对其编辑
未完待续...