關於hexo與github使用過程當中的問題與筆記

快速閱讀

如何用github 和hexo 建立一個bloghtml

1.github中要新建一個與用戶名同同樣的倉庫, 如:homehe.github.io

  • - 必須是io後綴。一個賬戶 只能創建一個

2. 綁定域名 , A記錄指向ip, cname記錄指向homehe.github.io

3. 配置sshkey

- 我的設置 -> SSH and GPG keys -> New SSH key
- 測試 是否成功 ssh -T git@github.com  =》You've successfully authenticated 表示成功
3.2 配置用戶名和郵件

$ git config --global user.name "liuxianan"// 你的github用戶名,非暱稱 $ git config --global user.email "xxx@qq.com"// 填寫你的github註冊郵箱java

4.安裝hexo

npm install -g hexo

在要目錄下進行初始化 hexo init=>會花費時間 長一點。

$ hexo g # 生成
$ hexo s # 啓動服務


hexo就會在public文件夾生成相關html文件,這些文件未來都是要提交到github去的:

hexo s是開啓本地預覽服務,打開瀏覽器訪問 http://localhost:4000 便可看到內容

若是端口被佔用:

這裏咱們以8081端口爲例講解。git

按下Win+R調出命令行窗口,輸入netstat -aon|findstr "8081",找到指定行最後一列的數字(PID),咱們這裏是9548. 輸入tasklist|findstr "9548",發現是javaw.exe佔用了8081端口。 再次輸入taskkill /f /t /im javaw.exe結束該進程。github

修改主題

//下載主題到themes/yilia 目錄
$ git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
修改_config.yml中的theme: landscape改成theme: yilia,而後從新執行hexo g來從新生成
關於yilia目錄的生成
在根目錄下運行
$ npm i hexo-generator-json-content --save

在根目錄下的_config.yml 中增長

jsonContent:
            meta: false
            pages: false
            posts:
              title: true
              date: true
              path: true
              text: false
              raw: false
              content: false
              slug: false
              updated: false
              comments: false
              link: false
              permalink: false
              excerpt: false
              categories: false
              tags: true

部署以前要安裝有關部署的

$ npm install hexo-deployer-git -save

關於部署的配置 ,注意:號後面必定要有空格 。

deploy:
  type: git
  repository: git@github.com:homehe/homehe.github.io.git
  branch: master

友情提示

​ 我對個人文章負責,發現好多網上的文章 沒有實踐,都發出來的,讓人走不少彎路,若是你在個人文章中遇到沒法實現,或者沒法走通的問題。能夠直接在公衆號《愛碼農愛生活 》留言。一定會再次複查緣由。讓每一篇 文章的流程都能順利實現。npm

相關文章
相關標籤/搜索