Hexo免费博客(WIN)

搭建环境

  1. 安装Node.jshttp://nodejs.org/en
  2. 安装Githttps://github.com/waylau/git-for-win
  3. 设置Git:直接打开Git Bash或者从开始->Git Bash。分别输入以下代码:
git config --global user.name "yourname"
git config --global user.email "[email protected]"

注意替换为自己的。

Git Bash 配置图

  1. 安装Hexo:在Git Bash输入
npm install -g hexo-cli

npm install -g -g的含义为全局安装。

这里需要等待一端时间。未出现 $ 表明正在下载安装。

Hexo安装完成

配置Coding或Github(这里以Coding为例)

创建仓库

coding1

coding2

加入密钥

Git Bash中输入:

ssh-keygen -t rsa -C "Coding或Github的注册邮箱地址"

会出现几个选择操作,不懂的默认,一路回车好了。

电脑目录C:\Users\你的用户名找到.ssh目录(没有的查看隐藏文件夹),进入,复制id_rsa.pub内容。

建议使用notepad打开文本。

coding3

复制到2.内

coding4

初始化博客

  1. 自行在本地创建文件夹。
  2. 在文件文件夹中右击选择Git Bash输入:
hexo init blog

成功会提示:!NFO Start blogging with Hexo!

  1. 本地预览一下

先确认下是否在blog目录下,若没有,输入:

cd blog
$ hexo generate
# 启动本地服务器
$ hexo server
# 在浏览器输入 http://localhost:4000/就可以看见网页和模板了
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

在浏览器中打开:localhost:4000

本地浏览

配置博客

blog目录下,用sublime/notepad++等文本编辑器打开_config.yml配置参数。

特别注意,每个参数后:后都有一个空格。

修改网站信息

title: 标题
subtitle: 副标题
description: 网页描述
author: 作者
language: zh-CN
timezone: Asia/Shanghai

配置部署信息

deploy:
  type: git
  repo: [email protected]:StarryTree/Hexo.git
  branch: master

repo:后的内容可以在Coding或Github仓库代码页找到。

配置统一资源定位符

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://starrytree.cn
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

如果有个人域名的话可以设置,否则跳过即可。如果是github.io的网址,也是可以填上的。

对于root(根目录)、permalink(永久链接)、permalink_defaults(默认永久链接)等其他信息保持默认。

因为coding分配的是目录,所以需要root: 项目名称

发表文章

  1. 新建博文:

Git Bash下输入:

hexo new "文章名称"

INFO Created: C:\1\document\Git\Hexo\blog\source_posts\Test.md

  1. 根据提示打开文件。

编辑需要使用markdown语法。Markdown 语法说明 (简体中文版)

建议头文档:

---
title: title #文章标题
date: 2017-09-08 23:47:44 #文章生成时间
categories: "Hexo教程" #文章分类目录 可以省略
tags: #文章标签 可以省略
     - 标签1
     - 标签2
 description: #你对本页的描述 可以省略
---
  1. 接着在blog目录下,输入如下的一系列(三个)命令:
F:\test\blog
$ hexo clean
INFO  Deleted database.
INFO  Deleted public folder.
$ hexo generate
INFO  Start processing
INFO  Files loaded in 1.48 s
#省略
INFO  29 files generated in 4.27 s
$ hexo server
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

本地预览:http://127.0.0.1:4000

  1. 发布到远端仓库。执行hexo deploy
F:\test\blog
$ hexo deploy
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
#省略

后记

补充

首次推送可能需要:

解决推送错误

首次推送后,请在coding代码页代开page服务。

猜你喜欢

转载自www.cnblogs.com/Cross-starry-sky/p/9144464.html