我創(chuàng)作了難道你不想低成本搭建個(gè)人博客嗎?我收到一些高手的留言,他們說他們用Hexo,其實(shí)我也嘗試是過hexo+github的方案,但是碰到一些問題一直沒有解決,世上無難事,只要肯放棄。但是今天!功夫不負(fù)有心人,我用hexo搭建了博客!
準(zhǔn)備
配置Hexo
在終端輸入
sudo npm install hexo-cli -g#因?yàn)槲沂莔ac,所以前面要加 sudo
hexo init blog
cd blog
npm install
hexo server
別看這短短的幾行,我還是掉坑里了
npm install 錯(cuò)誤
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/project_name/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-1065-aws
gyp ERR! command "/usr/local/bin/node" "/var/www/project_name/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "-libsass_library="
gyp ERR! cwd /var/www/front-stormsensor/node_modules/node-sass
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
如果出現(xiàn)以上錯(cuò)誤,在終端輸入:
sudo npm i --unsafe-perm
如果還不行,在終端輸入:
sudo rm -rf ~/.node-gyp
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i --unsafe-perm
bash: hexo command not found 問題解決
sudo npm install hexo-cli -g 時(shí)會(huì)有以下結(jié)果:
所以在需要hexo時(shí),都改為/Users/ ??/.npm-global/lib/node_modules/hexo-cli/bin/hexo
比如:/Users/a/.npm-global/lib/node_modules/hexo-cli/bin/hexo init blog
或者將其添加為環(huán)境變量。
Mac配置環(huán)境變量的地方
1./etc/profile (建議不修改這個(gè)文件 )
全局(公有)配置,不管是哪個(gè)用戶,登錄時(shí)都會(huì)讀取該文件。
2./etc/bashrc (一般在這個(gè)文件中添加系統(tǒng)級(jí)環(huán)境變量)
全局(公有)配置,bash shell執(zhí)行時(shí),不管是何種方式,都會(huì)讀取此文件。
3.~/.bash_profile (一般在這個(gè)文件中添加用戶級(jí)環(huán)境變量)
每個(gè)用戶都可使用該文件輸入專用于自己使用的shell信息,當(dāng)用戶登錄時(shí),該文件僅僅執(zhí)行一次!
修改配置文件
在blog 文件下 _config.yml 中修改大部分的配置
| title
| 網(wǎng)站標(biāo)題 |
| subtitle
| 網(wǎng)站副標(biāo)題 |
| description
| 網(wǎng)站描述 |
| author
| 您的名字 |
| language
| 網(wǎng)站使用的語言 |
| timezone
| 網(wǎng)站時(shí)區(qū)。Hexo 默認(rèn)使用您電腦的時(shí)區(qū)。時(shí)區(qū)列表。比如說:America/New_York
, Japan
, 和 UTC
。 |
修改主題
1.在Hexo主題下載主題
2.加壓到blog/themes下
3.在_config.yml中搜索theme
4.將其修改為解壓的主題文件名
部署到github
這個(gè)可以參考極客慕白