开发学习程序员Mac优雅使用指南

Mac上面如何搭建博客(Hexo)

2016-04-01  本文已影响463人  微pk笑

搭建博客

1. 安装brew包管理器。Mac自带ruby命令

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"```####2.安装Nodejs

2.安装nodejs

brew install node

3.安装hexo

npm config set registry=”[http://registry.cnpmjs.org](http://registry.cnpmjs.org/)“
sudo npm install -g hexo

4.初始化hexo

hexo init #执行init命令初始化到你制定的目录例如:hexo init hexo,则会在当前目录下生成hexo目录以下命令在hexo目录下执行。

5.安装依赖包1

npm install

6.生成静态网页123

hexo generate #自动根据当前目录下的文件,生成静态的网页或者hexo g

7.运行本地服务12345

hexo server或者hexo s此时在浏览器中输入 localhost:4000 ,可以查看静态网页

8.添加博文1234567

hexo new "post Name" #新建博文,其中postName是博文的题目例如:hexo n “微笑”刷新上述静态网页,可以看到新添加的一篇博文。PS:博文会自动生成在博客目录下souce/_posts/postName.md

9.部署到github

* 1.打开github.com,注册github的账户,并且创建仓库 sizhupo.github.io
* 2.配置ssh-keygit config –global user.email “邮箱的名字”git config –global user.name “你的用户名”ssh-keygen -t rsa -C “你的邮箱”回车三次,在~、.ssh/下生成id_rsa和id_rsa.pub两个文件复制id_rsa.pub文件内容到github账户下ssh keys 的新建key里面, add
* 3.修改hexo目录下的_config.yml,在最后添加以下内容
deploy:type: gitrepository: git@github.com:username/username.github.io.gitbranch: master
* 4.执行 npm install hexo-deployer-git –save
* 5.执行hexo g 和hexo d 完成部署

10.打开浏览器并且入username.github.io来查看你的博客


:详细请查看我的github地址:https://github.com/sizhupo/jiajia/tree/master/%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2

上一篇 下一篇

猜你喜欢

热点阅读