Mac下搭建目前最in的hexo博客

小巫打算把博客迁移到github中,为了让自己成为一名有逼格的程序员,我也是蛮拼的,所以搭建了一个hexo博客,可以尽情装逼,下面把搭建过程整理出来供大家参考。

迁移地址:www.devilwwj.com

step 1 申请域名

小巫这里是在新网申请的域名http://www.xinnet.com/,你们也可以去其他网站去申请域名。

我这里申请的时.com顶级域名,相对.cn .net要贵一些,为了省事,直接买了3年的域名使用期,各位自行选择即可。

step2 配置DNS解析

来到我的账号->我的域名,可以对域名进行续费、管理密码修改、mydns解析设置、域名过户;这里我们选中域名之后,再点击mydns解析设置来对我们的dns,如下图:

下面是我们对主机名(A记录)的添加,我们添加以下记录,IP对应的是github的IP

A记录IP
devilwwj.com192.30.252.153
devilwwj.com192.30.252.154
www.devilwwj.com192.30.252.153
www.devilwwj.com192.30.252.154

如下图所示:

step3 创建github仓库

自行注册github账号,然后创建github仓库

step4 下载Node.js

step5 安装npm

安装最新版的Node.js之后,我们就可以使用npm命令

在mac下遇到npm命令找不到的问题,解决方案如下:

sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf

step7 安装hexo

sudo npm install -g hexo

step8 创建hexo项目

通过命令行,在指定文件夹下创建项目:

sudo hexo init

到这里我们已经完成hexo的安装,具体效果如图所示:

step9 本地测试hexo

在命令行中输入sudo hexo server或者它的缩写sudo hexo s:

hexo devilwwj$ sudo hexo s
INFO  Hexo is running at http://0.0.0.0:4000/. Press Ctrl+C to stop.

然后我们可以在浏览器地址栏输入:localhost:4000,这样子我们可以本地测试我们搭建好的项目

step10 部署到github

在命令行中输入以下命令完成hexo的部署:

sudo hexo generate
sudo hexo deploy

也可以直接这样:

sudo hexo d -g


step11 绑定域名

如何让外网可以访问我们的网站,我们需要在source目录下创建一个CNAME,也就是我们的别名,然后重新部署到github当中

step12 更换皮肤

如果你对默认的皮肤不满意,可以通过克隆的方式,把别人的主题克隆过来:

git clone https://github.com/ppoffice/hexo-theme-hueman.git themes/hueman

然后再_config.yml,配置主题:

# Extensions 扩展:插件和皮肤
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: hueman

最后奉上_config.yml的配置:

# Hexo Configuration
## Docs: http://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site 站点信息
title: IT_xiao小巫
subtitle: 在浮躁的世界安安静静敲代码
description: IT_xiao小巫的blog | Android | java | Mac
author: devilwwj
language: zh-CN
email: 659982592@qq.com
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://www.devilwwj.com #你的域名
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory 文件目录
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing # 写文章选项
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight: # 代码高亮
  enable: true
  line_number: true # 是否显示行号
  tab_replace:

# Category & Tag 目录和标签
default_category: uncategorized
category_map:
tag_map:

# 归档设置
## 2: Enable pagination
## 1: Disable pagination
## 0: Fully Disable
archive: 2
category: 2
tag: 2

# Date / Time format 时间和日期格式
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination 页面
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions 扩展:插件和皮肤
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: hueman

# Disqus  disqus评论,  与多说类似, 国内一般使用多说
disqus_shortname: devilwwj

plugins: #插件,例如生成 RSS 和站点地图的
- hexo-generator-feed
- hexo-generator-sitemap

#Feed Atom
feed:
    type: atom
    path: atom.xml
    limit: 20
#sitemap
sitemap:
    path: sitemap.xml

# Markdown语法
## https://github.com/chjj/marked
markdown:
  gfm: true
  pedantic: false
  sanitize: false
  tables: true
  breaks: true
  smartLists: true
  smartypants: true


# Deployment 部署配置
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: https://github.com/devilWwj/devilwwjHexo.git #你的github page 仓库
  branch: gh-pages

如果大家对上面所述有不明白的地方,可以在下面留言,后续小巫不断对hexo进行优化,会把优化的方法总结成博文发表到本站,see you。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小巫技术博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值