Skip to main content

2 posts tagged with "blog"

View All Tags

· 3 min read

Imgur

在去年改用 Hexo1架部落格後,由於用 Markdown 寫起來更方便了,又有 Mermaid2語法支援可以快速畫出一些流程圖,因此多寫了幾篇。

在此期間,也陸續為這個部落格加了一些小功能。主要有

  • 將 Hexo 預設的 Markdown 引擎換成 markdown-it,以支援顏文字 (emoji)9 🎉
  • 加入類似 Medium 的文章預計閱讀時間 (每篇文章標題下方顯示 x min. read) ⏳
  • 支援腳注 (footnote)🔗 ,如下方的參考資料

為了折騰這些功能花了些時間,不知道這樣的投資能不能攤平到下個十年 :p

🔸 以下是在改進部落格的過程中發現的一些小知識:

將 Hexo 預設的 Markdown 引擎換成 markdown-it 🎉

為了要支援 emoji,在網上找到的做法是改用hexo-renderer-markdown-it3引擎並同時安裝markdown-it-emoji4 最後必要的是在_config.yml 裡加入相應的markdown設定5

加入類似 Medium 的文章預計閱讀時間 ⏳

原本我裝的是 hexo-reading-time6,整合好後一看,所有中文文章的閱讀時長都短得可以,讓我懷疑它根本沒有支援中文字數計算。後來找一找,才拿可支援中文字數計算的hexo-wordcount7來替換掉。隨後又丟了個 PR8過去來調整預設的閱讀時長,最終才接近想要的效果。

參考資料 📓

· 2 min read

Imgur

I just migrated my blog from Blogger to Github (via Hexo)! Because I'd like to use Markdown to write things efficiently (format, syntax highlight...), and think if I can finally integrate blog as part of my homepage (which soon or later will be hosted on github).

Migrate from blogger

To migrate from blogger, I use these instructions:

npm install -g hexo-cli
mkdir blog && cd blog
npm install --save hexo-migrator-rss
hexo migrate rss https://www.blogger.com/feeds/xxxxxxx/posts/default?max-results=600

xxxxxxx is your blog id which can be found from url bar of blogger's admin panel.

To test render result locally, run

hexo s --debug

To generate static file then update to github, run

hexo generate --deploy --debug

If you have amount of articles like me (about 500 articles), make sure you have allocate enough memory if you run the command in VM.

The template comes from hexo-theme-next with great document.

Make sure you've follow "Setting up a custom subdomain" , and install hexo-generator-cname to generate CNAME file for your static web site.

npm install --save hexo-generator-cname

Add cname property in _config.yml:

cname: blog.gasolin.idv.tw

You can check _config.yml and themes/ for my site configurations.

The theme customization is done via npm scripts. You can check package.json::scripts for detail.

deploy automatically via travis CI

Read

for step by step instructions. Or you can check My version of .travis.yml with hexo-theme-next gitsubmodule

SEO enhancements

Read 如何向 google 提交 sitemap (in chinese) to send sitemap.xml to google for better indexing.

Update theme

Use command

git submodule foreach git pull origin master

to update your theme. Read Update Git submodule to latest commit on origin for more detail.