Yu-Kai Lin
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    3
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 透過 Jekyll 與 GitHub Pages 經營個人網站 > 正式文章連結:https://stephlin.github.io/writing/2021/03/28/jekyll-github-pages.html 對於資訊工程師或者相關領域的人來說,「寫作」實際上是一種不管在分享資訊、統整知識、抑或形塑個人形象等等方面都有很多的好處,而若你本身對於網頁與架站具有一定程度的熟悉度,你也可以嘗試客製化自己的網頁,進而與其他人的網站做出差異性。 GitHub Pages 是一個支援靜態網頁的免費架站平台,提供 1 GB 的儲存空間以及免費且附 SSL 憑證的域名,因此如果你本身有在使用 GitHub 的話,實不失一個無償架站的好選項!本文將介紹透過 Jekyll 使用 GitHub Pages 的方式,以及一些網站主題的搜尋清單。 <!-- more --> ## 為什麼要寫文章? 我連用程式語言的時間都不夠了,還要用自然語言寫文章? 網路上不管在 Medium 或是個人平台上,也有不少人在探討寫作的好處。雖然這邊有一個小小的盲點是:那些寫文章的人在撰寫的同時就是在做這件事情---意思是說,我們似乎缺少了一些「不常寫文章的人」的意見,這邊不妨就筆者過去學習的經驗去嘗試闡述「寫作」的過程帶來的影響。 筆者從大一開始正式接觸資訊科學,並在大三大四兩年擔任系上的網管,並在以每週固定一個小時為週期的工讀生會議中,開始將過往的所學所知寫成文件,並與同儕及學弟妹分享在這個領域上的各種資訊。 分享資訊的傳統在過去這個工讀團隊中實際上一直存在,然而多數都是採取口頭傳授的方式進行,以至於許多知識在傳遞過程中難以被保存,並借鑑 Amazon 的開會方法[^storm-amazon-meeting-style][^bnext-amazon-meeting-style],故筆者決定採用文件的形式記錄開會中要講的事情,並且在會議中直接透過文件闡述,而當時筆者並沒有固定寫作的習慣。 [^storm-amazon-meeting-style]: [在亞馬遜,開會禁用PPT!來自貝佐斯的怒吼:「根本搞不清楚在講什麼」-風傳媒](https://www.storm.mg/article/1734921?page=1) [^bnext-amazon-meeting-style]: [禁止開會用PPT!貝佐斯為何在會議中要求所有人靜坐30分鐘? | 數位時代](https://www.bnext.com.tw/article/51020/amazon-use-memo-to-replace-ppt-in-meeting) ![](https://i.imgur.com/wRNnBzR.png) <small style="color: gray">當時筆者撰寫的內部會議文件,當時講述的內容是 SSO.</small> 倒是有個題外話,這個方案在實踐初期仍是一個草創階段,不諱言地,早期寫得實在有點爛,儘管畢業後在碩士班至今為止依舊維持這個形式,在每週進度報告中皆採取這個套路,但這個形式在寫作本身以及闡述上都有著更高的要求,因此至今筆者偶爾在報告時還是會發生「聽眾不知道講者到底在講什麼鬼東西」的窘境。 > 這也可能是筆者比較廢啦抱歉。 不過在筆者每週整理這些文件的過程中,會發現自己也在重新審視過去所學習的東西:首先找資料的過程中,不少會發現以前自己可能誤解的資訊;而在統整資訊的過程中,你會開始讓過去的所學與現在的資訊產生連結,並且讓整件事情是有連貫性的。最後就彷彿一個說書人在講故事般,在闡述的過程中讓各種元素之間的關聯性變強,進而將這些知識內化成一幅幅畫面,每每談起總能信手拈來。 這個現象實際上也在不少文章中有談到[^medium-huli-why-blogging][^medium-huli-blog][^dotblog-why-engineer-blogging][^yehjunwei-why-engineer-blogging],而綜合來說這些特點到最後都會回到個人身上:寫作文章的本身不只是讓讀者受益,真正得到最大幫助的實際上是作者本身!這也是筆者認為除了興趣之外,從理性層面來看工程師寫文章最重要、最有感的正面效益。 [^medium-huli-why-blogging]: [每一篇心得都有價值——為什麼初學者才更應該要寫心得筆記. 91 哥寫過一篇文章叫做《我為什麼鼓勵工程師寫… | by Huli | Huli’s blog | Medium](https://medium.com/hulis-blog/why-blogging-ab77fd8c6ffa) [^medium-huli-blog]: [我為什麼寫部落格,以及部落格帶給我的影響. 前幾天有個朋友問了我一個問題: | by Huli | Medium](https://hulitw.medium.com/blog-e7a23a74ae2b) [^dotblog-why-engineer-blogging]: [我為什麼鼓勵工程師寫 blog | In 91 - 點部落](https://dotblogs.com.tw/hatelove/2017/03/26/why-engineers-should-keep-blogging) [^yehjunwei-why-engineer-blogging]: [為何軟體工程師應該開始寫部落格(Blog) | Tony Yeh](https://www.yehjunwei.com/773/%E7%82%BA%E4%BD%95%E8%BB%9F%E9%AB%94%E5%B7%A5%E7%A8%8B%E5%B8%AB%E6%87%89%E8%A9%B2%E9%96%8B%E5%A7%8B%E5%AF%AB%E9%83%A8%E8%90%BD%E6%A0%BCblog) ## 透過 Jekyll 架設網站 在前言中提到,GitHub Pages 本質上提供靜態網站,因此任何途徑的終點都是靜態 HTML 頁面,而 Jekyll 是一個幫助你有組織地建構網頁的工具。 完整的安裝流程基本上還是建議讀者直接參考 [Jekyll 官方安裝說明文件](https://jekyllrb.com/docs/installation/),這邊筆者僅說明針對 Ubuntu 系統的安裝過程。 ### Step 1. 安裝 Ruby 及其套件管理器 RubyGems 總言之,直接上指令: ```bash sudo apt-get install ruby-full build-essential zlib1g-dev ``` 安裝指令成功後,接著將相關環境變數加到自己的環境設定檔: ```bash echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` ### Step 2. 安裝 Jekyll 與 Bundler 套件 透過 Step 1 取得的套件管理器 `gem` 安裝套件,指令如下: ```bash gem install jekyll bunder ``` ### Step 3. 初始化 Jekyll 專案 到這一步後基本上有兩條道路可以選:第一種是建立 Jekyll 預設環境,然後再自行安排 CSS、JavaScript 等個人化設計;第二種則是 clone 別人已經編排好的框架,之後再視個人狀況做些許微調。 #### Option 1. 建立 Jekyll 預設環境 假設專案根目錄為 `$YOUR_GITHUB_NAME.github.com`,你可以透過以下指令生成基本環境: ```bash jekyll new $YOUR_GITHUB_NAME.github.com ``` > 將專案根目錄取為 `$YOUR_GITHUB_NAME.github.com` 的目的在於之後 push 到 GitHub 時,你需要遵守 GitHub Pages 的命名規則。 接著在根目錄執行以下指令初始化,並啟動網站: ```bash cd $YOUR_GITHUB_NAME.github.com bundle install bundle exec jekyll serve --livereload ``` > `--livereload` 指令的目的在於當網頁資料有變動的時候,伺服器會自動重新編譯,致使寫作者不需要手動重新啟動服務 (但如果是設定檔相關的更動仍須自行重啟),留意自動刷新功能需要瀏覽器[擴充功能](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei)支援。 > 因為執行指令沒有很簡潔,因此筆者在使用的時候會在根目錄另外新增檔案 `Makefile`,內容為 > ``` > .PHONY: serve > serve: > bundle exec jekyll serve --livereload > ``` > 如此一來便可透過指令 `make serve` 取代上述指令。 此時在 localhost:4000 即可看到具備基礎功能的網站! ![](https://i.imgur.com/UNxmXWn.png) <small style="color: gray">範例網站首頁</small> #### Option 2. Clone 別人設計好的框架 筆者提供以下兩個地方可以尋找不錯的 Jekyll 主題: - http://jekyllthemes.org/ - https://github.com/topics/jekyll-theme 接著筆者以 [TeXt Theme](https://github.com/kitian616/jekyll-TeXt-theme) 為例,首先先透過 git 指令將原始碼載下來: ```bash git clone https://github.com/kitian616/jekyll-TeXt-theme $YOUR_GITHUB_NAME.github.com ``` 接下來同第一種路線,在根目錄初始化環境,並啟動網站: ```bash cd $YOUR_GITHUB_NAME.github.com bundle install bundle exec jekyll serve --livereload ``` 此時在 localhost:4000 即可看到網站! ### Step 4. 寫文章 我們快速理解一下 Jekyll 網站專案的資料夾架構: ``` . ├── 404.html ├── about.markdown ├── _config.yml ├── Gemfile ├── Gemfile.lock ├── index.markdown └── _posts ``` 其中 `_config.yml` 是網站環境設定檔,關於網站名稱、環境變數、乃至於 Markdown 語法設定細節都可以在這裡調整,而基本上文章都會放在 `_posts` 目錄底下,並且原生支援 Markdown 基本語法。 我們嘗試新增一個文章檔案 `_posts/2021-01-01-happy-new-year.md`,內容為 ``` --- layout: post title: "Happy New Year" date: 2021-01-01 categories: - jekyll - update tags: - new-year --- Happy new year! Hello 2021! ``` > `categories` 與 `tags` 屬性可以幫助你將文章進行分類,至於分類的呈現手法則要看不同主題的設計方式。 此時在網站上你就可以看到以下結果: | ![](https://i.imgur.com/QIlselI.png) | ![](https://i.imgur.com/3rQI5D3.png) | | ------------------------------------ | ------------------------------------ | <small style="color: gray">範例文章結果</small> ## GitHub Pages GitHub Pages 基本上依賴於 git repository,因此你不只需要一個 GitHub 帳號,也會需要一點 git 的基本概念。 對於 Option 1 的使用者,你會需要初始化 git 專案環境;而對於 Option 2 的使用者,則需要更改或新增 remote 對象。 而 GitHub Pages 默認倉儲名稱為 `$YOUR_GITHUB_NAME.github.com` 為 GitHub Pages 的目標倉儲,因此在命名上必須遵守這個規則,否則 GitHub Pages 相關程序不會被觸發。 > 在原理上被觸發的程序為 GitHub Actions (CI/CD),會經歷 Build 與 Deploy 這兩個步驟。 ![](https://i.imgur.com/fhesqpQ.png) <small style="color: gray">觸發 GitHub Actions 之視覺化效果,要看到勾勾才代表執行成功。</small> 一旦順利執行,此時前往以下網址 `https://$YOUR_GITHUB_NAME.github.io` 便可看到你在 GitHub Pages 的個人網站。 ## 結語 每個人的寫作歷程不盡相同,因此獲得的感想可能因人而異。若讀者認同寫作的重要性,並且對 Markdown 與網頁有一定了解的話,推薦你使用 GitHub Pages 作為工程師部落客旅程的起點!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully