一次Github+Hexo搭建个人博客的踩坑
起步
1.检查SSH keys的设置;如果没有显示“No such file or directory”,说明这是你第一次使用 git;
2. 生成新的 SSH Key:$ ssh-****** -t rsa -C "邮件地址@youremail.com"
;ssh-****** -t rsa -C "Github的注册邮箱地址"
;
3. 然后系统会要你输入密码:Enter passphrase (empty for no passphrase):<设置密码>Enter same passphrase again:<再次输入密码>
4.找到id_rsa.pub文件
5. Ctrl + a复制里面的所有内容,然后进入Sign in to GitHub:你的github主页点击头像后边的箭头,选Settings进入设置界面后在左侧选SSH and GPG keysNew SSH key ;点击添加Add SSH key
6. 测试是否配置成功ssh -T [email protected]
;
7.设置用户信息git config --global user.name "username"//输入注册时的username
;git config --global user.email "[email protected]"//填写注册邮箱
- 配置hexo;
_config.yml
是配置文件,在文件中打开它找到# Deployment
并配置它;repo写自己的地址就行了。该文件的具体配置见hexo;
注意注意,配置的时候一定,一定,一定要有一个空格在前面,都保持一致,要不然配置无效的。后面根本deploy不上github - 初始化hexo博客
hexo init [folder]
folder为文件夹名称,会自动创建; - 生成静态文件
hexo generate
简写hexo g
会生成public目录; - 开启服务
hexo server
简写hexo s
;然后打开http://localhost:4000即可看到hexo博客 - 生成博客
hexo new post ‘名称’
即可在source
文件夹下生成博客,可编辑md文件,编辑md文件是记得在前面加个空格,不然会报错,如下; - 清除数据和静态文件
hexo clean
; - 部署到github
hexo deploy
生成部署到githubhexo d -g
;然后打开http://你的用户名.github.io即可看到部署以后的网页; - 吐槽一下,
hexo init 文件名
从github上拉取资源真的很慢,好好等等吧。