攻城狮-web

如何创建自己的博客

创建属于自己的博客

安装 hexo

必须先安装node

1
2
3
4
打开git-bush,进入到一个合适的存放hexo的文件目录,直接运行
http://www.xp510.com/xiazai/Application/other/28541.html
使用npm先安装node
npm install -g hexo-cli

image
image
注意安装时的错误提示

搭建博客

1
安装完hexo之后,运行下面的三条命令,hexo init blog -> cd blog -> npm install

是你自己的文件夹名,比如博客的文件夹名称是blog

hexo init
image
cd blog
image

npm install(自动安装所需要的全部插件)
image
hexo s
image

1
建立起本地的服务器,默认端口4000,打开浏览器,网址http://localhost:4000就可访问自己的博客

切换主题

hexo 官方提供了大量的优秀主题,我现在使用的是next主题,官网(http://theme-next.iissnan.com/ Next )

主题代码拷贝

主题的拷贝也是直接使用 git 即可,首先进入到你博客的根目录blog,再打开 git-bash 运行

1
git clone https://github.com/iissnan/hexo-theme-next themes/next

image

启用主题

在博客根目录下找到 _config.yml 文件,找到里面的 theme,改为next
image

发布博客到coding

配置 hexo deploy
hexo 提供了一个部署命令 hexo deploy,首先需要安装一下 hexo-deployer-git插件

1
npm install hexo-deployer-git --save

image
记得配置config.yml

配置信息

1
2
3
4
5
6
# Site
title: Shally
subtitle: 码农的日常
description: start from zero
author: yangfang: zh-CN
timezone: Asia/Shanxi

配置统一资源定位符(个人域名)

url:http://inderstack.com
对于root(根目录)、permalink(永久链接)、permalink_default(默认永久链接)等其他信息保持默认

配置部署

1
2
3
4
deploy:
type: git
repo: https://github.com/bai1994/bai1994.github.io.git
branch: master

bai1994这是我的域名,这里请填写自己的域名(域名自己定义,要求简短有意义,符合标准的驼峰命名)