Hexo能够在不须要服务器的状况下快速的构建静态博客,这样能省一大笔服务器钱,而且使用GithubPage还能够省下来域名钱。因此Hexo能够说是一种“经济”的选择。html
在搭建Hexo以前,你须要确保有:node
在 Node.js Download 下载适合你电脑系统的Node.js版本。Windows系统直接选择“Windows安装包(.msi)”的x64(若是你的电脑是64位系统的话)。git
而后打开安装的文件,一路摁Next(在第二个须要打勾赞成用户协议)等待安装完成。github
hexo的安装很是简单,首先在Powershell执行:shell
npm install -g hexo
接下来找一个你喜欢的文件夹(必须是空的),进到文件夹中,摁住 Shift
而后右键,选择 在此处打开Powershell窗口
,执行:npm
hexo init
若是你没有Github帐号,到这里去注册一个服务器
好,若是你注册完了或者登陆好了,那么就来访问这里:建立新仓库hexo
把 RepoSitory Name
设为 【你的用户名】.github.io
,好比我叫waterblock79,那仓库名就应该是 waterblock79.github.io
。post
填完以后就点击下面的 Create repository
建立仓库。spa
接下来会跳转到仓库界面,复制并保存好这里的连接!
如今在Powershell中执行:(别忘了替换引号里的内容~)
git config --global user.name "你的Github用户名" git config --global user.email "你注册Github使用的邮件地址"
举个例子,就像这样:
git config --global user.name "waterblock79" git config --global user.email "waterblock79@outlook.com"
而后回到你刚刚的文件夹,打开文件夹中的 _config.yml ,找到最下面的 # Deployment,把内容改为:
# Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type: git repo: 【你刚刚建立的仓库的网址】 branch: master
好比:
# Deployment ## Docs: https://hexo.io/docs/deployment.html deploy: type: git repo: https://github.com/waterblock79/waterblock79.github.io branch: master
hexo new 【文章名】
来新建文章,在你的博客文件夹的/source/_posts中编辑文章,可使用Typora来编辑Markdown文件哦~
要上传文章?依次执行这三个命令便可
hexo clean hexo generate hexo deploy
(有可能会弹出一个Github的登陆框,输入本身的Github帐号邮箱和密码便可登陆)
上传完了文章,就来看看效果吧,博客会在 【你的Github名称】.github.io
等着你。