Hexo_github_搭建个人博客
个人博客搭建(github + nodejs + hexo + theme (3-Hexo)):
1.git 下载与安装
git 简介:
Git (/ɡɪt/)is a distributed version-control system(分布式版本控制系统) for tracking changes in source code during software development.It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows[clarification needed].
The reasons why we use git
git 下载与安装:
you can download : website
the installtion just follows the defalut.
git 使用:
git 中文教程: 廖雪峰git 教程
2.Nodejs 下载与安装
nodejs 简介:
As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. In the following “hello world” example, many connections can be handled concurrently. Upon each connection, the callback is fired, but if there is no work to be done, Node.js will sleep.
1 |
|
nodejs 下载与安装:
根据操作系统选择相应 ‘source code’ 或者 ‘pre-built installer’
安装过程保持默认设置即可
nodejs 使用:
官方手册 documentation
3.Hexo 下载与安装
Hexo 简介:
Hexo is a fast, simple and powerful blog framework. You write posts in Markdown (or other markup languages) and Hexo generates static files with a beautiful theme in seconds.
Hexo 下载与安装:
3.1. 命令行安装
1 | npm install hexo-cli -g |
windows 系统可能出现报错: win32 不支持 fsevents
, SKIPPING OPTIONAL DEPENDENCY, 不影响 hexo 基本功能
json optional dependencies
1 | WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\hexo-cli\node_modules\chokidar\node_module |
3.2.检查 hexo 是否已经安装成功:
1 | hexo version |
1 | hexo-cli: 4.2.0 |
3.3.初始化(文件克隆 hexo-starter、Submodule themes/landscape、;安装依赖)
1 | hexo init username.github.io |
初始化成功提醒:
1 | INFO Start blogging with Hexo! |
3.4.测试 本地服务 是否可以启动
1 | hexo server |
server 成功提醒INFO :
1 | INFO Validating config |
3.5. 生成 SSH Keys, 并添加至 github, 测试 本地与 github 通信是否成功
1 | ssh-keygen -t rsa -C "***@***.com" |
KEY 添加方法 : Github –> settings —> SSH keys setting
通信测试 :
1 | ssh -T git@github.com |
1 | Hi ***! You've successfully authenticated, but GitHub does not provide shell access. |
or
1 | $ ssh git@github.com |
1 | Hi ******! You've successfully authenticated, but GitHub does not provide shell access. |
3.6. 配置 SSH 服务 、_config.yml
文件 : 如未配置,则每次 hexo deploy
均需要输入用户名及密码:
1 | $ git config --global user.name "******"// github用户名 |
_config.yml
文件更改为:
1 | deploy: |
不当写法:此种写法为 hexo2.*
版本书写规则,执行 hexo d
时会导致报错 Deployer not found: github or Deployer not found: git
, 可通过安装插件解决 npm install hexo-deployer-git --save
1 | deploy: |
4. 域名解析:
添加域名解析后,可使个性化域名指向博客 。
为域名添加两条记录:
主机记录(@ ; www); 记录类型(A ; CNAME); 解析线路 (默认 ; 默认) ; 记录值 ( IP ; ***.github.io) ; TTL (10min ;10min)
IP 获取方式 :
1 | ping ***.github.com |
5. Hexo 使用教程(主题更换):
Hexo_github_搭建个人博客
http://example.com/2020/10/07/Hexo-and-Github-Based-Personal-Blogs/
install_url
to use ShareThis. Please set it in _config.yml
.