Hexo学习(1) Mac中Hexo与GithubPages环境搭建

来源:互联网 发布:java输入scanner 编辑:程序博客网 时间:2024/06/06 09:43

0. 资料

  • Github Pages官网
  • Hexo官网

1. node.js安装

node.js官网中下载安装。


2. Git安装

git官网下载安装。


3. Hexo安装

# 在mac中有权限问题# 为了防止后面的问题,所有命令都使用sudo# 安装hexosudo npm install hexo-cli -gsudo npm install hexo-server --save

4. Hexo本地测试

# 初始化Hexo文件夹,需要下载点东西# minions这个名字可以随便取sudo hexo init minions# 进入文件夹cd minions# 不知道做什么sudo npm install# 生成静态页面sudo hexo g# 本地测试,本地测试网页为http://localhost:4000sudo hexo s

5. Hexo发布

5.1. github pages设置

引用Github Pages官网

Head over to GitHub and create a new repository named username.github.io, where username is your username (or organization name) on GitHub.

根据Github官网中的例子,Github中Repo名称必须是用户名.github.io。向reposity中添加index.html之后,就可以通过http://username.github.io来访问网页了

5.2. hexo配置

# 在hexo目录中的_config.yml文件中进行配置# repo中可以使用https://username@github.com/username/username.github.io.git的形式,这样在每次提交时都需要输入密码deploy:  type: git  repo: git@github.com:irvingzhang0512/irvingzhang0512.github.io.git  # repo: https://irvingzhang0512@github.com/irvingzhang0512/irvingzhang0512.github.io.git

5.3. hexo执行发布命令

# 安装插件sudo npm install hexo-deployer-git --save# 执行命令sudo hexo d# 每次部署的步骤sudo hexo cleansudo hexo generatesudo hexo deploy

6. 遇到的问题

6.1. 各种本地权限问题

解决方案:不管什么命令,都加上sudo

6.2. Permission denied

  • 问题描述:在ssh -T git@github.com正常的情况下,sudo hexo d命令返回
  • 解决:其实我也不知道是怎么解决的,我做了以下操作:
    • git版本安装了旧版的1.9.5
    • 在repo中使用了https的,在输入了密码后成功提交。之后将repo改成git地址后就好了……
0 0
原创粉丝点击