In the previous section which we successfully used the hexo build a local blog, this section we will talk about how it will be deployed to Github blog home page
Use hexo + github build online personal blog
New github repository
Log on to their Github, create a new warehouse, named
username.github.io
, whichusername
is your user name, select the Initialiaze this repository with a README, creating depots, the process shown belowOnce created, selecting Settings, turn down Github Pages, as shown in FIG.
We have access to their own
username.github.io
, as shown in FigureReturns
username.github.io
warehouse, Git copy address, shown in FIG.
Local operation
The end of the above steps, we return to a local folder
We / Blog / hexo / folder, find the
_config.yml
file, open it with a text editor. as the picture showsThe lowest
deploy
change the content shown below, in which the repo address is the address we have just Git copy, modify, save and exit after the better.
[Note] modify the content:
there is a space between and behind the letters, otherwise the subsequent content will complainNext, we would not consider new article, run Git Bash in
npm install hexo-deployer-git --save
the command, wait for some time, as shown in Figure
The last execution
hexo deploy
orhexo d
[Note] This step is necessary to ensure public have the machine on Github, you can find their own solutions here, I ran into a problem: judging by the online method, I have successfully configured the public key, but each execution will let me enter the username and password againhexo d
Later, I found a way on the Internet:
- New system variable called
HOME
, the value of the variable%USERPROFILE%
- 在
C:/users
中的个人文件夹
下面新建一个名为_netrc
的文件,编辑内容为
machine github.com
login username
password userpassword
其中username
和userpassword
是Github的用户名和密码,这样就不必再重复输入用户名和密码了,但使用明文存储账号密码也存在不安全的风险
后来!当我在编辑博客的时候,我发现:即使删了这个文件,再去执行hexo d
也不需要输入用户名和密码了,原因不明。。。