Use Hexo established blog · Utopia's Daily Note on GitHub

Use Hexo a blog on GitHub

#

EDITORIAL

In fact, I wrote in the beginning of January on three of the blog post, you read right, just write three, then there is no then the. I was one of the articles written, they can not know how long. The fact is that, in order to adhere to about two days. Thus, stopping the update. It's really embarrassment. But, think about it now. Framework previously used this may indeed not as convenient. Before using a jekyll, in fact, by their own GitHub generate static pages. But always needs to be updated gh-Pages after submitting code. Feeling a little trouble. And sometimes there will still be delays to production. Always feel so happy. So in today Hexo chose to write their own blog site. Now it seems that based on node.js static page generator is good. I do not know what will happen subsequent performance. Anyway, it can be directly deployed configuration, this is still very good. There is a more detailed Chinese document, in fact, this point is still very attractive.

But in the process of deploying this Hexo in, there will be some problem is not the problem. I simply record what is better. After preventing me forget. In fact, one of the main purposes of writing a blog, is to own things done to have a place where you can easily access to record it. Otherwise, the story and sneered at the same. While in the efforts to solve the problem, while it is timely to solve the problem had forgotten.

When using GitHub set up their own free library, remember, GitHub page for Pages is a corresponding requirement, for example, can not be submitted more than 10 times per hour, there is a limit related capacity. These we can see their documents, there will be related to the introduction. However, the blog category page for general use should not exceed such limitations. Unless you are really very cow.

Here began the chase, how to use Hexo set up a blog on GitHub. The contents inside are basically collected from the network. So I will put in the end of the article which quoted article hyperlinks have left. This is also a practice academic. That is, you refer to someone else's content itself is fine, but if you do not say it, that's plagiarism. The protocol used by many open-source software is similar. You can use those codes. But the code of protocol and related information, you need to keep, at the same time, you want to use these programs in their program statements.

Use Hexo a blog on GitHub

First, you need to have a GitHub account

This said, the feeling is a joke, please do not laugh. Really someone will ignore this step. However, details, see related documents. This is not my focus to be described.

Establish the appropriate Respositiry on GitHub

Most documents are not here to tell you, in fact, in GitHub Pages function is divided into two. Are the User Pages and Project Pages, differences are as follows:

  User Page Project Page
Whether more An account is only one There may be a plurality of each of repo can have a corresponding Project page
Repo and Branch Repo name must be <username> .github.io, on page master Repo name at random, the page must be under the branch gh-pages
URL http(s)://<username>.github.io http(s)://<username>.github.io/<projectname>

GitHub1

Before I built a Pages page under the project to use, so it is necessary to use the project name to access. Now this is the use of user-level page, only this one. But really a lot shorter path. I am particularly lazy person, so I hope these things are as simple as possible.

Use Hexo established blog

Follow-up action is in accordance with OpnSuse I was using written, is similar in other operating systems.

Installation of dependencies Hexo preparations

其实在 Linux 这类系统使用这种编译的东西是很方便的。命令行可以很快的解决很多问题。比如官方文档提出需要 Git 和 Node.js .其实这两样在连着网的 Linux 下安装简直是很爽的。我看了一下,需要 npm,于是只要安装 npm 就好了, node.js 会自动以 npm 依赖的方式自动安装上的。

sudo zypper install npm

至于 Git 本来是基本每个常规 Linux 都自带的。即使没有初始化安装也可以通过类似的命令行进行安装。

安装 Hexo

sudo npm install -g hexo-cli

等着终端里的字符不滚动了,就会提示你已经安装好了。

建站

这个名称是来自与官方文档的,总感觉怪怪的。

安装 Hexo 完成后,请执行下列命令,Hexo 将会在指定文件夹中新建所需要的文件。

hexo init <folder>

配置

这个时候,进入刚才生成的那个文件夹。可以在 _config.yml 中修改大部份的配置。

网站

大专栏 使用 Hexo 在 GitHub 上建立博客 · Utopia's Daily Note  
参数 描述
title 网站标题
subtitle 网站副标题
description 网站描述
author 您的名字
language 网站使用的语言

其中,description 主要用于 SEO,告诉搜索引擎一个关于您站点的简单描述,通常建议在其中包含您网站的关键词。author 参数用于主题显示文章的作者。

网址

参数 描述 默认值
url 网址  
root 网站根目录 :year/:month/:day/:title/
permalink_defaults 永久链接中各部分的默认值  

网站存放在子目录 如果您的网站存放在子目录中,例如 http://yoursite.com/blog ,则请将您的 url 设为 http://yoursite.com/blog 并把 root 设为 /blog/。

我只是改了上面的两部分的内容,还有有别的内容,可以参考一下官方文档。

生成静态页

其实,在生成这个项目的时候,是自带了一个示例页面的。位置在 resourse/_post 下。格式是 markdown 的。基本上都是在写这个格式。不用担心排版的事情,还是很省心的。

hexo g

此时会生成静态页面,页面存放在项目下面的 public 文件夹下。

在这个时候其实你有两种选择发布这些页面,一种就是通过 Git 客户端,直接把这些页面放置在 master 分支下。还有一种选择,就是使用这个框架自带的发布工具。

使用 Hexo 自带工具发布

首先要执行的就是安装一个依赖工具。记住,不要偷懒,不要省略后面的 –sava 参数。我省略了,然后就不能正常工作。

sudo npm install hexo-deployer-git --save

然后回到 _config.yml 中修改参数。

参数 描述
repo 库(Repository)地址
branch 分支名称。如果您使用的是 GitHub 或 GitCafe 的话,程序会尝试自动检测。
message 自定义提交信息

在这个步骤上我也出现过错误。就是在啊设置仓库地址的时候。最好是从 github 上直接粘贴那个地址。而不是使用有些文章中所说的地址。

配置妥当以后,执行如下命令:

hexo d

这个命令会直接把本地的代码推送至你的 GitHub 仓库。

刷新浏览器就应该能够看到已经存在的示例页面了。

写篇文章

其实这个框架还有一个好处是可以直接通过命令生成一个空文章。之前我用的框架,我是没有发现有这个功能。虽然不复杂。但是很好用啊。

hexo new [layout] <title>

我还没有尝试这里使用中文的名字。我一般是先用英文,然后进入以后,把里面的 title 字段再改为中文的。

关于布局还是有3种的,这里用了默认的布局。默认布局也是可以随时通过调整配置文件来调整的,很方便。

至此,基本上就可以使用这个框架来写文章了。不过突然我想着要加个图片。这可以有两种方式。一种是通过七牛的云服务来实现的。这个载入速度会很快。而且还并不占用你的 GitHub 空间。很好。还有就是简单一些的。当 Hexo 项目中只用到少量图片时,可以将图片统一放在 source/images 文件夹中,通过 markdown 语法访问它们。

放置路径:

source/images/image.jpg

Reference Methods article:

![](/images/image.jpg)

If there is anything else to add, I might write a new, dry or wrong then write it back.

Reference Documents

  1. Use GitHub to blog in several ways

  2. How do I set up a blog is (github pages + HEXO + binding domain)

  3. hexo official documents

  4. Hexo blog to build a picture of the insert in the article

  5. Static deployment Hexo blog to seven cattle

Guess you like

Origin www.cnblogs.com/lijianming180/p/12041344.html