Github build a blog and use Hexo station

I am computer system window 10 Professional Workstation, 64

The steps:

1, install and configure Node.js Node.js environment, open cmd command line interface follows the successful

 

 2, install and configure Git Git environment, the installation is a symbol of success in any location on your computer right mouse follows two options can appear

 

Note: For security reasons generally only be related operations in Git Git Bash Here in. If you need to call in Git cmd command line, then it would have to configure the computer's environment variables Path, or select use Git when installed from the Windows Command Prompt. This is optional, it has little effect on the success of the configuration of the interface shown

 

 3, Github account registration and a new project, the project must comply with the format: account name .github.io, otherwise then there will be a lot of trouble. And the need to check the Initialize this repository with a README

 

On the right side of the project has built a settings button, click on it, pulled down GitHub Pages, you will see the other side there is a web site, visit it, you will be surprised to find that the project has been deployed to the network, can external network to access it. 

 

 4, installation Hexo, they think in the right place to create folders, I was in the D drive to build a blog folder. Then into the folder inside the command line

 

Enter npm install hexo -g, start the installation Hexo

 

Enter hexo -v, check whether the installation was successful hexo

 

Enter hexo init, to initialize the folder (bit of a long wait ...)

See "Start blogging with Hexo!" Behind, excitement there are wood! ! ! ! !

 

Input component npm install, the installation required

 

Enter hexo g, for the first time to experience Hexo

 

 Enter hexo s, turn on the server, access the web site, the official experience Hexo

Question: If the page has been unable to jump, then the port may be occupied. At this point we ctrl + c to stop the server, then enter "hexo server -p port number" to change the port number

Then appears as shown on the success of

 

 

 5、将Hexo与Github page联系起来,设置Git的user name和email(如果是第一次的话)

 

上图是在其文件夹里面鼠标右键,点击Git Base Here。这里“feng”可以替换成自己的用户名,邮箱可以替换成自己的邮箱

 

输入cd ~/.ssh,检查是否由.ssh的文件夹

 

输入ls,列出该文件下的内容。下图说明存在

 

 输入ssh-keygen -t rsa -C “[email protected]”,连续三个回车,生成密钥,最后得到了两个文件:id_rsa和id_rsa.pub(默认存储路径是:C:\Users\Administrator\.ssh)。

 

 

 输入eval "$(ssh-agent -s)",添加密钥到ssh-agent

 

 再输入ssh-add ~/.ssh/id_rsa,添加生成的SSH key到ssh-agent

 

 登录Github,点击头像下的settings,添加ssh

 

 

新建一个new ssh key,将id_rsa.pub文件里的内容复制上去

 

输入ssh -T [email protected],测试添加ssh是否成功。如果看到Hi后面是你的用户名,就说明成功了

问题:假如ssh-key配置失败,那么只要以下步骤就能完全解决

首先,清除所有的key-pair
ssh-add -D
rm -r ~/.ssh
删除你在github中的public-key

重新生成ssh密钥对
ssh-keygen -t rsa -C "[email protected]"

接下来正常操作
在github上添加公钥public-key:
1、首先在你的终端运行 xclip -sel c ~/.ssh/id_rsa.pub将公钥内容复制到剪切板
2、在github上添加公钥时,直接复制即可
3、保存

测试:
在终端 ssh -T [email protected]

 

6、配置Deployment,在其文件夹中,找到_config.yml文件,修改repo值(在末尾)

 

 

repo值是你在github项目里的ssh(右下角)

 

7、新建一篇博客,在cmd执行命令:hexo new post “博客名”

 

 这时候在文件夹_posts目录下将会看到已经创建的文件

 

在生成以及部署文章之前,需要安装一个扩展:npm install hexo-deployer-git --save

 

使用编辑器编好文章,那么就可以使用命令:hexo d -g,生成以及部署了

 

 

部署成功后访问你的地址:http://用户名.github.io。那么将看到生成的文章

 

 好了,到此为止,最基本的也是最全面的hexo+github搭建博客完结。接下来是进阶的操作

Guess you like

Origin www.cnblogs.com/wenhainan/p/10942919.html