建立个人博客

序言

虽然各种博客平台都挺不错的,但我还是想有一个自己的博客,我没有什么计算机及计算机网络基础,找到一个HEXO基础教程,想跟着教程先试试

教程

Parry Qiu:https://www.youtube.com/watch?v=Ud1xAhu7t2Y&list=PLXbU-2B80FvDjD_RiuNwsSQ4eF8pkwAIa
周三 Tech:https://www.youtube.com/watch?v=B0yVJ46CTR8&list=PLD5dyQmlN6xPqBV0cxO7zAe1C8OmDPqfX

Hexo介绍

Hexo官网:https://hexo.io/

简介:Hexo 是一个基于nodejs 的静态博客网站生成器,作者是来自台湾的 Tommy Chen

安装Hexo

安装Node.js和Git

Node.js:https://nodejs.org/zh-cn/
Git:https://git-scm.com/download/winddddda

在命令行里检查是否安装了Node.js和Git

Node.js版本查看

1
node -v

Git版本查看

1
git version

安装Hexo

npm换为淘宝的源

1
npm config set registry https://registry.npm.taobao.org

配置后可通过下面方式来验证是否成功

1
npm config get registry

所有必备的应用程序安装完成后,即可使用 npm 安装 Hexo

1
npm install -g hexo-cli

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

1
2
3
hexo init <folder>
cd <folder>
npm install

注:Hexo不兼容PowerShell,所以在创建网站页面时要用命令行

生成网站

1
hexo g

查看服务器

1
hexo s

配置文件

在hexo文件下面,_config.yml是hexo的配置文件,可以在其中修改大部分配置,其遵循YAML语法

Hexo官网上对于配置的参考:https://hexo.io/zh-cn/docs/configuration

写作

生成博客文章

通过命令 hexo new [layout] <title>即可在目录下生成新的博客文章,如

1
hexo new "建立个人博客"

然后需要再次生成网页 hexo g,生成之后再次运行服务器 hexo s

生成草稿文章

通过命令 hexo new draft [layout] <title>生成草稿文章

生成页面

hexo new page [layout] <title>

这些页面的模板都处于scaffolds文件夹下

Hexo部署到Git

首先安装hexo-deployer-git

1
npm install hexo-deployer-git --save

运行以下代码查看是否成功安装

1
npm list hexo-deployer-git

如果看到插件对应的版本,说明插件已成功安装

在github上以以下格式创建仓库:

1
<username>.github.io

接下来,到configure文件里更改以下选项

1
2
3
deploy:
type: git
repo: <Your github repository>

运行 hexo d
即可将hexo部署到github上
此时遇见windows下常见github错误 fatal: unable to auto-detect email address,因为github的密码没有被正确识别
运行以下命令重新设置git的配置文件

1
git config --global credential.helper wincred

当他出现这两个提示

1
2
3
4
5
6
*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

按提示输入邮箱和用户名就行

现在,hexo就部署好了,输入 https://<username>.github.io即可进入博客

三行命令

清除缓存

1
hexo clean

上传到github

1
hexo g

部署

1
hexo d

Live2D

详细信息:https://github.com/EYHN/hexo-helper-live2d/blob/master/README.zh-CN.md

进阶:https://github.com/stevenjoezhang/live2d-widget

ayer主题手册

ayer:https://shen-yu.gitee.io/2019/ayer/

  • Copyrights © 2021 红磷椰子
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信