Hao Dawei
    • 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

      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.
      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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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

    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.
    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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ![CleanShot 2024-11-16 at 12.01.42@2x](https://hackmd.io/_uploads/BycqFcHf1g.png) # 如何用 MkDocs 製作個人網站部署在 github.io ## 簡介 [`MkDocs`](https://www.mkdocs.org/) 是一個快速、簡單、漂亮的靜態網站生成器,特別適合用來建立專案文件。本指南將介紹如何使用 Material for MkDocs 主題建立個人網站。 ## 基礎安裝 ```bash # 安裝 MkDocs 核心套件和 Material 主題 pip3 install mkdocs mkdocs-material # 建立新的 MkDocs 專案 # my-site 是專案名稱,可以自行更改 mkdocs new my-site cd my-site ``` ## 了解網頁建置的內容說明 下面是 `mkdocs.yml` 的範例,附帶詳細註解: 基本上 yml 這個檔案會是建立整個網頁內容結構,可以用來定義所要呈現的內容。 ```yaml # ===== 基本設置 ===== # 網站名稱,會顯示在瀏覽器標籤和導航列 site_name: Da-Wei # 網站 URL,通常是 GitHub Pages 的位址 site_url: https://dwhao84.github.io/ # 作者資訊 site_author: Da-Wei, Hao # 網站描述,用於 SEO site_description: Dawei's introduction # ===== 主題設置 ===== theme: # 使用 Material 主題 name: material # 設定語言為繁體中文 language: zh-Hant # 設定網站 logo(路徑相對於 docs 目錄) logo: assets/logo.png # 設定網站圖示 favicon: assets/square-code.png # ----- 功能設定 ----- features: # === 導航功能 === - navigation.tabs # 頂部顯示主要分類標籤 - navigation.sections # 側邊欄分區顯示 - navigation.expand # 自動展開導航項 - navigation.top # 顯示返回頂部按鈕 - navigation.footer # 顯示頁腳導航 - toc.follow # 目錄跟隨滾動 # === 搜尋功能 === - search.highlight # 搜尋結果高亮顯示 - search.share # 可分享搜尋結果 - search.suggest # 搜尋建議 # === 內容功能 === - content.code.copy # 程式碼區塊可複製 - content.tabs.link # 分頁內容可連結 # === 進階功能 === - navigation.tracking # 跟蹤導航位置 - navigation.instant # 即時頁面切換 - header.autohide # 滾動時自動隱藏頁首 - announce.dismiss # 可關閉公告 # ----- 配色方案 ----- palette: # === 亮色主題 === - media: "(prefers-color-scheme: light)" # 系統使用亮色模式時 scheme: default # 使用默認配色 primary: deep purple # 主要顏色 accent: purple # 強調顏色 toggle: icon: material/weather-sunny # 切換按鈕圖示 name: 切換至深色模式 # 切換按鈕提示文字 # === 暗色主題 === - media: "(prefers-color-scheme: dark)" # 系統使用暗色模式時 scheme: slate # 使用石板配色 primary: purple # 主要顏色 accent: deep purple # 強調顏色 toggle: icon: material/weather-night # 切換按鈕圖示 name: 切換至淺色模式 # 切換按鈕提示文字 ``` ## 網站結構說明 ```plaintext docs/ # 文件根目錄 ├── index.md # 首頁文件 ├── techstack.md # 技術棧介紹頁面 ├── work_experience/ # 工作經歷目錄 │ └── resume.md # 履歷文件 ├── projects/ # 專案作品目錄 │ └── Drink_Order_App.md # 專案介紹 └── contact.md # 聯絡方式頁面 ``` ## Navigation設置 ```yaml # 定義網站的導航結構 nav: - 首頁 / Home Page: index.md # 首頁連結 - 關於我 / About Me: # 關於我區段 - techstack.md # 技術棧頁面 - 工作經歷 / Working Experience: # 工作經歷區段 - work_experience/resume.md # 履歷頁面 - 專案作品 / Projects: # 專案作品區段 - projects/Drink_Order_App.md # 專案介紹頁面 - 聯絡方式 / Contact: contact.md # 聯絡方式頁面 ``` ## Markdown 擴展功能 由於網站的內容,都是用Markdown的方式來編寫,所以在編輯上有Markdown語法支援是蠻方便的是,下列是語法支援: ```yaml markdown_extensions: - tables # 支援表格功能 - attr_list # 支援屬性列表 - md_in_html # 支援在 HTML 中使用 Markdown - pymdownx.highlight: # 程式碼高亮 anchor_linenums: true # 行號錨點 - pymdownx.superfences # 支援高級圍欄程式碼區塊 - admonition # 支援提示區塊 - pymdownx.details # 支援可折疊區塊 - pymdownx.tabbed: # 支援分頁內容 alternate_style: true - footnotes # 支援腳註 - def_list # 支援定義列表 - pymdownx.tasklist: # 支援任務列表 custom_checkbox: true # 自定義核取方塊樣式 - toc: # 目錄設置 permalink: true # 顯示標題永久連結 - pymdownx.emoji: # Emoji 支援 emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_generator: !!python/name:material.extensions.emoji.to_svg ``` ## 社群連結設置 ```yaml extra: social: # GitHub 連結 - icon: fontawesome/brands/github link: https://github.com/dwhao84 name: GitHub # Medium 連結 - icon: fontawesome/brands/medium link: https://medium.com/@dwsamurai84_dev name: Medium # Email 連結 - icon: fontawesome/solid/envelope link: mailto:dwsamurai84@gmail.com name: Email ``` ## 部署步驟 ```bash # 本地預覽:啟動開發伺服器 mkdocs serve # 部署至 GitHub Pages:自動建立並推送到 gh-pages 分支 mkdocs gh-deploy ``` ## 其他功能配置 ### Google Analytics ```yaml extra: analytics: provider: google property: !ENV GA_TRACKING_ID # 需要替換為實際的 GA 追蹤碼 ``` ### Cookie 提示 ```yaml extra: consent: title: Cookie 同意 # 提示標題 description: >- # 提示描述 我們使用 Cookie 來識別您的重覆訪問和偏好設定... ``` ### 插件優化 ```yaml plugins: - search # 搜尋功能 - tags # 標籤系統 - minify: # 最小化檔案 minify_html: true # 最小化 HTML minify_js: true # 最小化 JavaScript minify_css: true # 最小化 CSS ``` ## 注意事項 1. **資源文件**: - 確保所有圖片、圖示等資源文件放在 docs/assets/ 目錄下 - 檔案名稱建議使用英文,避免特殊字符 2. **開發流程**: - 修改配置後需要重新啟動 `mkdocs serve` - 建議先在local預覽確認無誤後再部署 3. **部署相關**: - 確保 GitHub 儲存庫已開啟 Pages 功能 - 部署時需要有網路連接 ## 常見問題解決 1. **部署失敗**: - 檢查 GitHub 儲存庫設定 - 確認有正確的提交權限 2. **套件相關**: - 使用 `pip3 list` 確認所有依賴都已安裝 - 可能需要更新套件版本 3. **語法問題**: - YAML 檔案對縮排敏感,使用空格而非 Tab - 確保所有冒號後面有空格 ## 參考資源 - [MkDocs 官方文件](https://www.mkdocs.org/) - [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) - [PyMdown Extensions](https://facelessuser.github.io/pymdown-extensions/) ## 如何放在 github.io 可以參考下列內容: [ 一分鐘在GitHub建立個人網站!](https://ithelp.ithome.com.tw/m/articles/10259505)

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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