補覺鳴詩

學海無涯


  • 首頁

  • archive

  • 關於我

  • 搜尋

hugo host in github

時間: 2022-02-19   |   分類: hugo   | 字數: 739 字 | 閱讀: 2分鐘 | 閱讀次數:

在此網站建立時順手作的紀錄文章

github 提供一個功能 叫做 GitHub Pages

GitHub Pages 讓 github 帳號建立 repository 後 讓該 repository 能夠以靜態網頁呈現內容

好處是你不需要有 server 、 DNS domain 就能夠使用 當使用 markdown 編寫文件,並結合 Jekyll 就能產生簡易的部落格

在此指之前我都使用 GCP 開一個永久免費的 VM 架設 wordpress 使用

論功能來說 wordpress 較強大 但文件應用彈性,使用 markdown 會較容易 比如說我可以將筆記功能與網站結合,而不需要發布兩個地方

GitHub Pages 介紹可以使用 Jekyll 作為網站生成器 但評估後,覺得 HUGO 似乎較符合我 所以這網站就以 HUGO 建立

建置流程簡介

  • 建立 github 帳號並建立 2 個 repository
  • 下載網站生成器 hugo
  • 下載 VScode、gitdesktop
  • 生成網站、文章
  • 發佈到 github

建立 github 帳號並建立 2 個 repository

github 預設會將 <username>.github.io 這個 Repository name 直接對應到 https://<username>.github.io 這個 domain 如果你想要使用其他 Repository name 也是可以設定為虛擬目錄使用

這邊我們建立兩個 repository 一個用為供 public 瀏覽用 另一個做為我們網站程式碼的保存用 (這步驟就非必要)

以我舉例我分別建立 lovesharepc.github.io 權限: public hugo_sitetool 權限: private

img

下載 VScode、github desktop

下一步 我們要準備好開發工具

VScode 可以作為多功能的編輯器(包含 markdown) https://code.visualstudio.com/

GitHub Desktop 則是用來將我們的網站 push 到網路上 https://desktop.github.com/

下載網站生成器 hugo

到 hugo 的 github 下載執行檔

https://github.com/gohugoio/hugo/releases

在電腦上建立目錄 hugo_sitetool 使用 github desktop 將 github reopsitory clone 至此

將 hogo 檔案放置此處 並設定環境變數 1645361618677.png

1645361632407.png

開啟 terminal 軟體嘗試執行 hugo 確認是否能正常運作 hugo help

PS D:\Gdrive\hugo_sitetool\quickstart> hugo help
hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.

Complete documentation is available at http://gohugo.io/.

Usage:
  hugo [flags]
  hugo [command]

Available Commands:
  completion  generate the autocompletion script for the specified shell
  config      Print the site configuration
  convert     Convert your content to different formats
  deploy      Deploy your site to a Cloud provider.
  env         Print Hugo version and environment info
  gen         A collection of several useful generators.
  help        Help about any command
  import      Import your site from others.
  list        Listing out various types of content
  mod         Various Hugo Modules helpers.

1645361655004.png

生成網站、文章

這邊簡單的流程說明如下 首先建立網站

hugo new site quickstart

參考 quick-start 設定 Theme

接著建立目錄 public 將 github repository (lovesharepc.github.io) clone 至此

然後執行 hugo 編譯網站,網站就準備好發布了

發佈到 github

發布很簡單 就是使用 github desktop commt 變更並 push 至 github

hugo_sitetool 要將 public 目錄排除掉

之後到 https://lovesharepc.github.io/

就能看到自己網站的成品了

#hugo#
comments powered by Disqus >
  • 文章目錄
  • 網站導覽
Owan

Owan

愛貓如癡

131 日誌
29 分類
37 標籤
GitHub
  • 建置流程簡介
    • 建立 github 帳號並建立 2 個 repository
    • 下載 VScode、github desktop
    • 下載網站生成器 hugo
    • 生成網站、文章
    • 發佈到 github
© 2010 - 2022 補覺鳴詩
Powered by - Hugo v0.96.0 / Theme by - NexT
0%