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

作者: 微pk笑 | 来源:发表于2016-04-01 17:26 被阅读463次

搭建博客

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

相关文章

网友评论

  • ITJason:我也是用 Mac + Hexo 来写博客的,握爪~

    不知道楼主是怎么解决 Hexo 插图的问题?我之前手动链接本地图片、再将图片上传至 Hexo。但这个过程麻烦,且在部署到 Github 时会担心图片会降低访问速度。

    最近搞了个 iPic 专门解决博客插图的问题:监控剪贴板中的图片、自动上传至微博图床、保存图片链接至剪贴板;这样,直接在 Markdown 编辑器中粘贴即可。感兴趣可以到这里了解下:http://i.toolinbox.net/iPic/iPicIntroduce3.html

本文标题:Mac上面如何搭建博客(Hexo)

本文链接:https://www.haomeiwen.com/subject/ukeylttx.html