GitHub、Node.js和Hexo搭建个人博客

GitHub、Node.js和Hexo搭建个人博客

1.Git

1.1、下载

下载地址:https://git-scm.com/downloads

1.2、Git安装

双击安装,点击Next

这里写图片描述

填写安装路径,点击Next

这里写图片描述

选中安装内容,点击Next

这里写图片描述

Select Start Menu Folder

这里写图片描述

Choosing the default editor used by Git

这里写图片描述

Adjusting your PATH environment

这里写图片描述

Choosing HTTPS transport backend

这里写图片描述

Configuring the line ending conversions

这里写图片描述

Configuring the terminal emulator to use with Git Bash

这里写图片描述

Configuring extra options

这里写图片描述

点击Finish

这里写图片描述

查看版本

这里写图片描述

2.Node.js

2.1、下载

下载地址:https://nodejs.org/zh-cn/download/

2.2、Node.js安装

双击安装,点击Next

这里写图片描述

End-User License Agreement

这里写图片描述

Destination Folder

这里写图片描述

Custom Setup

这里写图片描述

Ready to install Node.js

这里写图片描述

点击Finish,安装完成

这里写图片描述

查看版本

这里写图片描述

3.Hexo

3.1、安装Hexo

新建一个hexo文件夹作为安装目录

这里写图片描述

进入hexo目录,右击选择Git Bash Here

这里写图片描述

打开后如图

这里写图片描述

输入下面命令进行安装

npm install hexo-cli -g
  • 1

这里写图片描述

等待上个命令运行完,运行初始化命令、npm命令和开启服务命令

hexo init
npm install
hexo server
  • 1
  • 2
  • 3

这里写图片描述

打开服务后,访问上述http路径,看到如图,hexo安装成功

这里写图片描述

如果4000端口访问不了,需要修改端口 
第一种方式:

$ hexo server -p 4001
  • 1

第二种方式: 
在_config.yml文件内添加如下内容

server: 
  port: 4001
  compress: true
  header: true
  • 1
  • 2
  • 3
  • 4

4.绑定域名

登录github,新建一个仓库

这里写图片描述

仓库名要和owner一致,并以github.io为后缀

这里写图片描述

在windows的cmd终端下ping 仓库路径,得到ip4的地址,也是你的github服务器地址

这里写图片描述

购买域名后,进入域名管理,点击解析

这里写图片描述

点击新手引导,并在记录值中输入ping的ip4地址,点击确认

这里写图片描述

点击确认

这里写图片描述

在source目录新建一个CNAME文件,去掉后缀名,强制确认 
这里写图片描述

用文本格式打开CNAME文件,并输入域名

这里写图片描述

进入创建的仓库,选择setting,找到Github Pages,填写域名

这里写图片描述

以文本的形式打开_config.yml文件

这里写图片描述

修改type为git,修改repo为github仓库地址(注意yaml文件的冒号后面有一个空格)

deploy: 
   type: git
   repo: https://github.com/simba1949/simba1949.github.io.git
  • 1
  • 2
  • 3

这里写图片描述

在Github Pages中显示,说明域名绑定成功(不过新注册的域名需要备案才能使用)

这里写图片描述

通过域名访问页面

这里写图片描述

5.上传到GitHub上

输入命令,进行生成

$ hexo g
  • 1

输入命令,进行部署

$ hexo d
  • 1

附录一 Hexo命令地址

https://hexo.io/zh-cn/docs/index.html

附录二 Hexo主题地址

https://hexo.io/themes/

附录三 安装npm

安装npm

npm install npm -g
  • 1

附录四 ERROR Deployer not found: git

npm install --save hexo-deployer-git
  • 1

附录五 上传github失败

输入一下命令,再重新部署

npm install hexo-deployer-git --save  
  • 1

附录六 Git安装:

安装
next 下一步
设置目录
勾选需要的项:
Additional icons是关于图标的设置
In the Quick Launch是快速启动图标
On the Desktop是桌面快捷方式
Windows Explorer integration是资源管理器集成(右键菜单)
Git Bash Here是在当前目录运行Git命令行
Git GUI Here是在当前目录运行Git原生界面
ssociate .git* configuration files with the default text editor是将所有.git开头的文件使用默认文本编辑器打开
Associate .sh files to be run with Bash是将所有扩展名为.sh的文件使用Git命令行执行
Use a TrueType font in all console windows是在所有命令行(包括Windows系统cmd命令行窗口)中都使用TrueType字体
是否创建在开始菜单中? Don‘t create... 不创建。
环境设置
Use Git from Git Bash only不会修改系统环境变量,但是Windows系统cmd命令行中无法使用git命令
Use Git from the Windows Command Prompt会将git相关程序加入系统环境变量中,使得Windows系统cmd命令行中可以使用git命令
Use Git and optional Unix tools from the Windows Command - Prompt会将git相关程序以及一些其他的Unix工具加入系统环境变量,使得Windows系统cmd命令行中可以使用git以及Unix工具
选择库
use the openssl library 使用OpenSSL库
use the native windows secure channel library 使用本机Windows安全通道库
转行规则
Checkout Windows-style, commit Unix-style line - endings选项让Git能够自动转换文件中的换行符;签出到本地时转换为Windows下的换行符,提交到服务器时转换为Unix下的换行符
Checkout as-is, commit Unix-style line endings选项让Git在签出到本地时不做转换,保留原始文件的换行符;提交到服务器时转换为Unix下的换行符
Checkout as-is, commit as-is让Git在签出到本地时和提交到服务器时都不做转换
使用控制台程序
Use MinTTY (the default terminal of MSys2) 选项使用一款叫做MinTTY的软件作为Git命令行,MinTTY是一款模拟Unix系Bash终端的软件。优点是命令记录、可配置字体、可改变窗口大小等等,缺点是可能无法直接运行原Windows下的一些命令行程序
Use Windows‘ default console windows选项使用Windows系统cmd命令行来作为Git命令行。优点和缺点正好和上一个选项相反。
其他选项
Enable file system chaching 启用文件缓存
Enable Git Credential Manager 启用凭据管理
Enable symbolic links 启用符号链接
等待安装进度。
Launch git Bash 现在启动
View release notes 查看发行说明
等待安装完成后,在CMD命令中输入git或者git --version命令查看是否安装成功。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog

猜你喜欢

转载自blog.csdn.net/weixin_42246997/article/details/80863942