把blog由wordpress轉移到hexo(下)
Hexo小心得
從wordpress直接導入
安裝plugin
npm install --save-dev hexo-migrator-wordpress
注意這個plugin並不會把圖片自動下載 我是另外寫了一個script把圖片都下載並加入到項目當中 好一點當然是上傳到一些永久的空間(如cloudinary之類)
SEO配置
加入sitemap及rss feed
npm install --save-dev hexo-generator-feed
npm install --save-dev hexo-generator-sitemap
當然每個post你也應該設定一個好的slug及相關的tags
## 自訂theme
安裝hexo時就已經預載了一個theme於目錄./themes/ 中
最簡單的方法就是直接修改
或者可以使用其他人所寫的theme
摘要excerpt
在文章中加入以下script會自動生成文章摘要
Facebook留言
安裝plugin
npm install --save-dev hexo-fbcomments
修改_config.yaml
# Enable facebook comments
fbcomments:
enabled: true
lang: zh_HK
appId: [facebook_app_id]
numPosts: 20
發佈到github pages
先建立相應的github repo並新增一個orphan branch 可以看這裡 {% post_link travisci-publish-github-pages.md 利用TravisCI直接發佈靜態網頁到Github Pages %}
然後安裝plugin
npm install --save-dev hexo-deployer-git
更改_config.yaml
# Deployment
# Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: [email protected]:[username]/[reponame].git
branch: gh-pages
message:
利用command發佈
hexo generate --deploy