<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Hugo 自架站｜林鼎淵 Dean Lin</title>
    <link>https://deanlin.net/series/hugo/</link>
    <image><url>https://deanlin.net/images/author_hu_aa256fc934e9a932.jpg</url><title>Hugo 自架站｜林鼎淵 Dean Lin</title><link>https://deanlin.net/series/hugo/</link><width>144</width><height>144</height></image>
    <description>用 Hugo 從零打造個人品牌網站：挑選主題、設定參數、撰寫文章、部署到 GitHub Pages，再串接 Google Analytics 與 Search Console。</description>
    <generator>Hugo</generator>
    <language>zh-tw</language>
    <copyright>© 2020–2026 林鼎淵 Dean Lin</copyright>
    <lastBuildDate>Tue, 21 Jan 2025 22:07:47 +0800</lastBuildDate>
    <atom:link href="https://deanlin.net/series/hugo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>[Hugo自架站-6]設定 Google Search Console，讓自己的網站可以被搜尋</title>
      <link>https://deanlin.net/blog/202501/hugo6-set-up-google-search-console/</link>
      <pubDate>Tue, 21 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo6-set-up-google-search-console/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>這篇文章要教大家如何設定 Google Search Console，以及上傳網站的 Sitemap（網站地圖），讓自己的網站可以被搜尋。</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/cover_hu_bc40db2c9fae3a69.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/cover_hu_b9ccfc1f7f15d36c.webp" width="1440" height="748" alt="〈設定 Google Search Console〉封面" fetchpriority="high" decoding="async"></p>
<p>上篇文章分享了如何<a href="https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/">在網站安裝 Google Analytics（GA）來分析網站的瀏覽數據</a>，而這篇文章要教大家如何設定 Google Search Console，以及上傳網站的 Sitemap（網站地圖），讓自己的網站可以被搜尋。</p>
<h3 id="驗證自己的網站是否能被-google-搜尋">驗證自己的網站是否能被 Google 搜尋<a class="h-anchor" href="#%e9%a9%97%e8%ad%89%e8%87%aa%e5%b7%b1%e7%9a%84%e7%b6%b2%e7%ab%99%e6%98%af%e5%90%a6%e8%83%bd%e8%a2%ab-google-%e6%90%9c%e5%b0%8b" aria-label="這個段落的連結"></a></h3>
<hr>
<p>在 Google Search 的搜尋框輸入 <code>site:你的網址</code>，ex: site:dean9703111.github.io</p>
<p>如果搜尋結果為「請使用 Google Search Console」，就代表你的網站尚未被 Google 收錄，別人也無法從 Google 找到你的網站。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/gooogle_search_site_hu_9df86250470a5bda.webp" width="1440" height="563" alt="Google 用 site: 指令搜尋網站，查無結果" loading="lazy" decoding="async"></p>
<h3 id="設定-google-search-console">設定 Google Search Console<a class="h-anchor" href="#%e8%a8%ad%e5%ae%9a-google-search-console" aria-label="這個段落的連結"></a></h3>
<p>點擊「請使用 Google Search Console」便會進入如下頁面：</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/gsc_hu_4ad3d00c71610ab.webp" width="1440" height="717" alt="Search Console 選擇資源類型的歡迎頁" loading="lazy" decoding="async"></p>
<p>因為目前的網域是使用 GitHub 的，所以要選擇「網址前置字元」，並貼上自己 GitHub 的網址。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/gsc2_hu_b1b758510491a18a.webp" width="1440" height="717" alt="網址前置字元欄位填入 GitHub Pages 網址" loading="lazy" decoding="async"></p>
<p>如果你有跟著<a href="https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/">上一篇文章乖乖設定 GA</a>，就會直接驗證通過。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/gsc3_hu_8efc91594d3b5dd4.webp" width="1440" height="764" alt="Search Console 已透過 GA 自動驗證擁有權" loading="lazy" decoding="async"></p>
<h3 id="上傳-sitemap-到-google-search-console">上傳 Sitemap 到 Google Search Console<a class="h-anchor" href="#%e4%b8%8a%e5%82%b3-sitemap-%e5%88%b0-google-search-console" aria-label="這個段落的連結"></a></h3>
<hr>
<p>點擊「前往資源」後，選擇左側的「Sitemap」，直接貼上 <code>sitemap.xml</code> 點擊提交就好了！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/sitemap_hu_36dc7a9ad1d431ae.webp" width="1440" height="764" alt="新增 Sitemap 欄位填入 sitemap.xml" loading="lazy" decoding="async"></p>
<blockquote>
<p>Hugo 專案的 Sitemap（網站地圖）通常是放在「public/sitemap.xml」這個位置，裡面會存放網站所有可點擊的路徑。</p>
</blockquote>
<p>剛提交的 sitemap 可能會看到如下的畫面，狀態顯示「無法擷取」。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/sitemap2_hu_f77ef373370905c7.webp" width="1440" height="764" alt="已提交的 Sitemap 狀態顯示「無法擷取」" loading="lazy" decoding="async"></p>
<p>關於這個問題，Google 官方有給了一些<a href="https://support.google.com/webmasters/answer/7451001?hl=zh-Hant">解決方案</a>，網路上也看到有遇到相同問題的人。但如果你的 Sitemap 結構沒有擅自更改，通常是 Google 的奇怪 Bug，可能等一段時間什麼事都沒做就自動恢復了。</p>
<p>但因為筆者有購買自己的網域，所以沒有等他到的狀態轉為成功；由於 SEO 是跟著網址走的，所以這邊是「強烈」建議購買一個自己的網域，相對來說比較不會遇到這些奇怪的狀況（<strong>下圖是筆者換成自己的網域，試一次就成功了</strong>）。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/sitemap3_hu_83721bd94fbc9d69.webp" width="1440" height="675" alt="換成自訂網域後 Sitemap 狀態顯示成功" loading="lazy" decoding="async"></p>
<h3 id="驗證能否在-google-搜尋到自己的網站">驗證能否在 Google 搜尋到自己的網站<a class="h-anchor" href="#%e9%a9%97%e8%ad%89%e8%83%bd%e5%90%a6%e5%9c%a8-google-%e6%90%9c%e5%b0%8b%e5%88%b0%e8%87%aa%e5%b7%b1%e7%9a%84%e7%b6%b2%e7%ab%99" aria-label="這個段落的連結"></a></h3>
<hr>
<p>在 Google Search 的搜尋框輸入 <code>site:你的網址</code>，如果搜尋得到，就代表你設定成功了！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/sitemap4_hu_d1c4f24aa51883c1.webp" width="1333" height="886" alt="Google 用 site: 指令搜尋到網站頁面" loading="lazy" decoding="async"></p>
<p>把 Sitemap 提交後，可能要等一段時間文章才會被 Google 收錄；你可以稍微等等，又或是手動把網址輸入到 Google Search Console 上，並要求他「建立索引」（檢索是有可能發生錯誤的，可以多提交幾次嘗試看看）。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo6-set-up-google-search-console/sitemap5_hu_7a5c016e6e788897.webp" width="1440" height="773" alt="Search Console 網址檢查結果與要求建立索引按鈕" loading="lazy" decoding="async"></p>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<hr>
<p>以上就是 Hugo 架站的完整教學，做到這邊就完成一個 60 分的網站了。</p>
<p>之所以會說是 60 分，是因為還有許多可以優化的地方，下面舉幾個案例：</p>
<ol>
<li><strong>網站外型優化</strong>：目前套用的是預設模板，可能有些設計跟你的期待不符，但這塊優化就需要一些網頁前端（Frontend）的基礎能力了，ChatGPT 是你成長的好夥伴。</li>
<li><strong>Open Graph</strong>：如果你把部落格文章分享給朋友，會發現連結沒有縮圖；我們需要增加 OG 標籤，才能讓網站在社群上被漂亮分享。</li>
<li><strong>canonical URL</strong>：接下來筆者打算將 Medium 文章搬到自己的部落格，為了讓 Google 了解相同內容的狀況下哪篇文章才是本尊，就需要設定這個參數，否則你部落格的流量可能會被其他網站搶走。</li>
</ol>
<p>接下來會找時間繼續分享這些細節，不想錯過的朋友可以先追蹤<a href="https://www.facebook.com/deanlinbao">筆者的 FB</a> 喔！</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>[Hugo自架站-5]安裝 Google Analytics 追蹤網頁的流量與成效</title>
      <link>https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/</link>
      <pubDate>Mon, 20 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>如果想知道訪客的行為和網站的成效，就要安裝 Google Analytics（GA）。Google Analytics 是一個功能強大的免費工具，可以讓你了解訪客的來源、行為，以及網站上的哪些內容最受歡迎。如果你想持續優化網站的 SEO，GA 就像一個指南針，告訴你正確的執行方向！</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/cover_hu_785798b6a013b812.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/cover_hu_1b915076e2b84bb7.webp" width="1440" height="750" alt="〈安裝 Google Analytics 追蹤網頁流量〉封面" fetchpriority="high" decoding="async"></p>
<p><a href="https://deanlin.net/blog/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/">將網站部署到 GitHub Pages 後</a>，如果想知道訪客的行為和網站的成效，就要安裝 Google Analytics（GA）。</p>
<p>Google Analytics 是一個功能強大的免費工具，可以讓你了解訪客的來源、行為，以及網站上的哪些內容最受歡迎。</p>
<p>如果你想持續優化網站的 SEO，GA 就像一個指南針，告訴你正確的執行方向！</p>
<h3 id="註冊-google-analytics-帳號">註冊 Google Analytics 帳號<a class="h-anchor" href="#%e8%a8%bb%e5%86%8a-google-analytics-%e5%b8%b3%e8%99%9f" aria-label="這個段落的連結"></a></h3>
<hr>
<p>可以用 Google 帳號登入 Google Analytics: <a href="https://analytics.google.com/">https://analytics.google.com/</a></p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga_hu_59e9da7d0a1fb5a4.webp" width="1440" height="678" alt="Google Analytics 建立帳戶步驟，填寫帳戶名稱" loading="lazy" decoding="async"></p>
<p>接下來會要你填寫一些資訊，下面是參考：</p>
<ul>
<li><strong>帳戶名稱</strong>: 隨意填</li>
<li><strong>屬性名稱</strong>: 可以填 GitHub 帳號</li>
</ul>
<p>另外產業類別等其他選項，依照自己實際狀況填寫即可，到最後一步的時候，我們直接選擇「網站」來做設定。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga2_hu_5937c6962d984936.webp" width="1440" height="678" alt="Google Analytics 資料收集步驟選擇網站平台" loading="lazy" decoding="async"></p>
<p>網址的部分選擇貼上先前建立的 GitHub Pages 的網址，然後給他取一個名字就好</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga3_hu_cb87b1cc4bde9eea.webp" width="1440" height="678" alt="GA 設定資料串流，填入網站網址與串流名稱" loading="lazy" decoding="async"></p>
<h3 id="取得-google-analytics-提供的追蹤碼">取得 Google Analytics 提供的追蹤碼<a class="h-anchor" href="#%e5%8f%96%e5%be%97-google-analytics-%e6%8f%90%e4%be%9b%e7%9a%84%e8%bf%bd%e8%b9%a4%e7%a2%bc" aria-label="這個段落的連結"></a></h3>
<hr>
<p>這邊我們直接點擊剛剛建立的資源。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga4_hu_72e19c21dd4e4e8e.webp" width="1440" height="678" alt="GA 資料串流列表中剛建立的網站串流" loading="lazy" decoding="async"></p>
<p>然後選擇「查看代碼操作說明」。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga5_hu_38f05e7b7b505d7f.webp" width="1440" height="678" alt="網頁串流詳情中的「查看代碼操作說明」按鈕" loading="lazy" decoding="async"></p>
<p>點擊右側的「手動安裝」，然後將下方程式碼複製下來。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga6_hu_6567368c33814815.webp" width="1440" height="678" alt="GA 手動安裝分頁中的 gtag.js 追蹤碼" loading="lazy" decoding="async"></p>
<h3 id="將-google-analytics-追蹤碼放到-hugo-模板">將 Google Analytics 追蹤碼放到 Hugo 模板<a class="h-anchor" href="#%e5%b0%87-google-analytics-%e8%bf%bd%e8%b9%a4%e7%a2%bc%e6%94%be%e5%88%b0-hugo-%e6%a8%a1%e6%9d%bf" aria-label="這個段落的連結"></a></h3>
<hr>
<p>然後把畫面切到 Hugo 專案，打開「themes/liva-hugo/layouts/partials/head.html」，滑到最下方，在 <code>&lt;/head&gt;</code> 標籤上方貼上程式。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga7_hu_ec056c0105cd378c.webp" width="1440" height="660" alt="head.html 底部貼上的 gtag.js 追蹤碼" loading="lazy" decoding="async"></p>
<p>然後將原本 google analitycs 的程式刪除。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga8_hu_142e000015064ed4.webp" width="1440" height="727" alt="head.html 中要刪除的舊版 GA 程式碼" loading="lazy" decoding="async"></p>
<p>然後打開「hugo.toml」，搜尋「Google Analitycs」，將這兩行刪掉，這樣就能移除舊版 GA 的設定了。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga9_hu_43b5f6e4eb13a30c.webp" width="1440" height="500" alt="hugo.toml 中要刪除的 GA ID 設定" loading="lazy" decoding="async"></p>
<h3 id="測試-google-analytics-是否設定成功">測試 Google Analytics 是否設定成功<a class="h-anchor" href="#%e6%b8%ac%e8%a9%a6-google-analytics-%e6%98%af%e5%90%a6%e8%a8%ad%e5%ae%9a%e6%88%90%e5%8a%9f" aria-label="這個段落的連結"></a></h3>
<hr>
<p>使用 <code>Hugo</code> 指令產生新的 public 資料夾，然後將資料夾底下的檔案拖到 GitHub Pages 的 Repository，如果對步驟不熟悉，可以<a href="https://deanlin.net/blog/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/">先回顧上一篇文章</a>。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/hugo_hu_d8b77663a7f34311.webp" width="1440" height="539" alt="終端機執行 hugo 指令後的建置結果" loading="lazy" decoding="async"></p>
<p>將版本更新推送到 GitHub 後，先前往自己部署的 GitHub Pages 的網頁刷新一下。</p>
<p>接著回到 GA 管理的頁面，點擊「首頁」，如果看到「已啟用資料收集功能」就大功告成了！你會在下方看到活躍的使用的人數！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo5-install-google-analytics-to-track-website-traffic/ga10_hu_d20d0c1efdcdd0d5.webp" width="1440" height="669" alt="GA 首頁顯示已啟用資料收集與活躍使用者人數" loading="lazy" decoding="async"></p>
<blockquote>
<p>有時 GA 的反應沒那麼快，可能會顯示「尚未收到資料」；你可以多重新整理頁面幾次，通常等個 5 分鐘就會收到資料了。</p>
</blockquote>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<hr>
<p>完成上面的設定後，你就可以透過 GA 的報表來觀察部落格網頁的流量了～</p>
<p>但現在網站還無法在 Google 被搜尋到，所以<a href="https://deanlin.net/blog/202501/hugo6-set-up-google-search-console/">下一篇文章要分享如何設定 Google Search Console</a>。</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>[Hugo自架站-4]將網站部署到 GitHub Pages</title>
      <link>https://deanlin.net/blog/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/</link>
      <pubDate>Sun, 19 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>設定好網站的基礎資訊，以及準備好第一篇部落格文章後。只要跟著教學操作，就可以將 Hugo 網站部署到 GitHub Pages 了！</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/cover_hu_469182012a599eef.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/cover_hu_413f7f44e0a4a6a5.webp" width="1440" height="750" alt="〈將網站部署到 GitHub Pages〉封面" fetchpriority="high" decoding="async"></p>
<p>設定好網站的基礎資訊，以及準備好第一篇部落格文章後，跟著教學的步驟操作，就可以將網站部署到 GitHub Pages 了！</p>
<h3 id="在-github-新增一個自己名字的-repository">在 GitHub 新增一個自己名字的 Repository<a class="h-anchor" href="#%e5%9c%a8-github-%e6%96%b0%e5%a2%9e%e4%b8%80%e5%80%8b%e8%87%aa%e5%b7%b1%e5%90%8d%e5%ad%97%e7%9a%84-repository" aria-label="這個段落的連結"></a></h3>
<hr>
<p>登入 <a href="https://github.com/">GitHub</a> 後，用 <code>自己的帳號名稱.github.io</code> 來新增一個 Repository。</p>
<p>以筆者來說，就是用 <code>dean9703111.github.io</code>，這將會是你日後個人品牌的部落格網址；另外記得要選擇「Public」才能讓大家看得到。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/new_repository_hu_3ae9ff478d06ba2.webp" width="1440" height="800" alt="GitHub 建立以帳號命名的 github.io 儲存庫" loading="lazy" decoding="async"></p>
<blockquote>
<p>小提醒：如果你帳號建立時跟筆者一樣沒想太多，導致字數超長，這在日後也是可以更新成自己的網域喔！</p>
</blockquote>
<h3 id="把-hugo-public-下的資料夾搬到剛剛建立的-repository-下">把 Hugo Public 下的資料夾搬到剛剛建立的 Repository 下<a class="h-anchor" href="#%e6%8a%8a-hugo-public-%e4%b8%8b%e7%9a%84%e8%b3%87%e6%96%99%e5%a4%be%e6%90%ac%e5%88%b0%e5%89%9b%e5%89%9b%e5%bb%ba%e7%ab%8b%e7%9a%84-repository-%e4%b8%8b" aria-label="這個段落的連結"></a></h3>
<hr>
<p>先前我們都是用 <code>hugo server</code> 來啟動網站，現在只需要執行 <code>hugo</code> 即可。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/command_hugo_hu_a8b4ba9924f45a23.webp" width="1440" height="562" alt="終端機執行 hugo 指令產生靜態網站" loading="lazy" decoding="async"></p>
<p>然後直接將生成的「public」資料夾下的內容搬到剛剛建立的 Repository 下即可。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/public_hu_bc9bad5022171b9a.webp" width="1440" height="606" alt="Finder 顯示搬進儲存庫的 public 網站檔案" loading="lazy" decoding="async"></p>
<h3 id="將變更-push-到-github-上面">將變更 Push 到 GitHub 上面<a class="h-anchor" href="#%e5%b0%87%e8%ae%8a%e6%9b%b4-push-%e5%88%b0-github-%e4%b8%8a%e9%9d%a2" aria-label="這個段落的連結"></a></h3>
<hr>
<p>接下來可以使用任何你習慣的版控工具來將變更推到 GitHub 上面，下面筆者是用 VSCode 來輸入 commit（描述調整），以及做 <code>git push</code>。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/vscode_hu_5b40213647109253.webp" width="1440" height="841" alt="VS Code 原始檔控制輸入 init 並提交變更" loading="lazy" decoding="async"></p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/git_push_hu_372a81492b5545ed.webp" width="1384" height="668" alt="終端機執行 git push 推送到 GitHub" loading="lazy" decoding="async"></p>
<h3 id="到-github-確認確認部署狀況">到 GitHub 確認確認部署狀況<a class="h-anchor" href="#%e5%88%b0-github-%e7%a2%ba%e8%aa%8d%e7%a2%ba%e8%aa%8d%e9%83%a8%e7%bd%b2%e7%8b%80%e6%b3%81" aria-label="這個段落的連結"></a></h3>
<hr>
<p>回到 GitHub 網頁，如果右下角的「Depoyments」是綠色勾勾，基本上就沒問題了！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/github_page_hu_4225f223a82471d3.webp" width="1440" height="913" alt="GitHub 儲存庫 Deployments 顯示部署成功" loading="lazy" decoding="async"></p>
<p>接者瀏覽網址（這是筆者的）: <a href="https://dean9703111.github.io">https://dean9703111.github.io</a></p>
<p>就可以順利看到自己的網站與發表的文章嚕！給自己拍拍手！現在可以將個人網站分享給其他人嚕～</p>
<p><img src="https://deanlin.net/images/post/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/web_page_hu_e526c62bb6f3166d.webp" width="1440" height="942" alt="部署完成的部落格首頁，列出 Hugo 自架站系列文章" loading="lazy" decoding="async"></p>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<hr>
<p>儘管看起來很美好，但其實還有如下細節需要設定:</p>
<ol>
<li><a href="https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/"><strong>Google Analytics</strong>: 用來追蹤網站流量成效</a></li>
<li><a href="https://deanlin.net/blog/202501/hugo6-set-up-google-search-console/"><strong>Google Search Console</strong>: 讓自己的網站在 Google 可以被搜尋到</a></li>
<li><strong>個人網域</strong>: 購買個人網域可以讓品牌看起來更專業，且轉換平台時 SEO 不會被綁架</li>
</ol>
<p>這些細節，筆者也會在<a href="https://deanlin.net/blog/202501/hugo5-install-google-analytics-to-track-website-traffic/">後續的文章</a>與大家分享。</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>[Hugo自架站-3]用 Markdown 撰寫文章，掌握分類、標籤文章的技巧</title>
      <link>https://deanlin.net/blog/202501/hugo3-write-first-post-hugo-markdown-tags/</link>
      <pubDate>Sat, 18 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo3-write-first-post-hugo-markdown-tags/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>這篇文章會先簡述常見的 Markdown 語法，讓大家了解如何在文章設定大標題、小標題、引述、圖片...等資訊。然後示範為文章加上「分類（category）、標籤（tag）」，讓我們能輕鬆管理自己部落格的文章。最後分享筆者推薦的檔案命名規則，以及文章資料夾結構。</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo3-write-first-post-hugo-markdown-tags/cover_hu_977ad5f3fdfcf051.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo3-write-first-post-hugo-markdown-tags/cover_hu_1a6c8c00e90b734b.webp" width="1440" height="796" alt="〈用 Markdown 撰寫文章，掌握分類、標籤的技巧〉封面" fetchpriority="high" decoding="async"></p>
<p><a href="https://deanlin.net/blog/202501/hugo2-setup-hugo-site-parameters/">完成 Hugo 外觀的基礎建設後</a>，接下來就可以開始撰寫部落格文章了。</p>
<p>這篇文章會先簡述常見的 Markdown 語法，讓大家了解如何在文章設定大標題、小標題、引述、圖片&hellip;等資訊。</p>
<p>然後示範為文章加上「分類（category）、標籤（tag）」，讓我們能輕鬆管理自己部落格的文章。</p>
<p>最後分享筆者推薦的檔案命名規則，以及文章資料夾結構。</p>
<h3 id="使用-markdown-語法來撰寫文章">使用 Markdown 語法來撰寫文章<a class="h-anchor" href="#%e4%bd%bf%e7%94%a8-markdown-%e8%aa%9e%e6%b3%95%e4%be%86%e6%92%b0%e5%af%ab%e6%96%87%e7%ab%a0" aria-label="這個段落的連結"></a></h3>
<hr>
<p>過去我們使用 Word，會需要使用上面的工具列來設定文章的標題、列表、粗體、斜體。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo3-write-first-post-hugo-markdown-tags/word_hu_64b418df66779e81.webp" width="1324" height="198" alt="Word 常用工具列的字型、粗體、斜體與清單按鈕" loading="lazy" decoding="async"></p>
<p>而 Markdown 則是用「符號」來設定，範例如下：</p>
<pre tabindex="0"><code>「#」開頭的就是標題，數量越少，字體越大，層級越高

# 大標題 h1

#### ▋小標題 h4

這邊就是描述的內容，你可以使用「-」的符號層級:

- 文字的格式
  - 要增加子階層，多兩個空格就可以
  - **粗體**
  - *斜體*
  - ~刪節線~

&gt; 引用的寫法
</code></pre><p>假使想顯示單行程式，可以用 1 個反引號「`」包起來。</p>
<p><code>console.log('單行程式');</code></p>
<p>如果想在某個區塊展示程式或是文字，可以將他們用 3 個連續的反引號包起來「```」</p>
<pre tabindex="0"><code>// 可以放程式語言、文字
console.log(&#39;程式碼區塊&#39;);
</code></pre><p>用 <code>[超連結](網址)</code> 的結構，就能在文字插入超連結，比如放上筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 連結。</p>
<p>用 <code>![img](/images/path)</code> 的結構，則可插入圖片。</p>
<blockquote>
<p>讀者可以到「content/blog」底下新增一個「test.md」的文章，測試不同符號對排版的影響。</p>
</blockquote>
<h3 id="掌握分類標籤文章的技巧">掌握分類、標籤文章的技巧<a class="h-anchor" href="#%e6%8e%8c%e6%8f%a1%e5%88%86%e9%a1%9e%e6%a8%99%e7%b1%a4%e6%96%87%e7%ab%a0%e7%9a%84%e6%8a%80%e5%b7%a7" aria-label="這個段落的連結"></a></h3>
<hr>
<p>從「content/blog」底下隨便點開一篇文章，你會發現最上方有些參數可以設定，下面向大家解釋每個參數代表的意義。</p>
<pre tabindex="0"><code>---
title: &#34;文章標題&#34;

# 文章撰寫的時間（新的文章會優先顯示）
date: 2025-01-16T22:07:47+08:00

# 文章是否為草稿，若設定為 true 就不會顯示在頁面上
draft: false 

# 部落格文章封面縮圖
image: &#34;images/post/post-3.jpg&#34;

# 文章的簡短介紹
description: &#34;這是分享文章連結時，會顯示的簡短描述&#34;

# 文章的分類
categories: 
  - &#34;Hugo 架站教學&#34; # 方便使用者在右側篩選（若是新增的分類，就會需要重啟 Hugo 才會生效）
tags:
  - &#34;Hugo&#34; # 這裡的標籤，會在首頁呈現（若是新增的標籤，就會需要重啟 Hugo 才會生效）
  - &#34;Web&#34;
  - &#34;自架站&#34;
  - &#34;教學&#34;

# post type
type: &#34;post&#34; # 原則上維持不變，因為目前都是要貼部落格文章
---
</code></pre><h3 id="設定-shortscodes-插入-youtube-影片ig-貼文">設定 shortscodes 插入 Youtube 影片、IG 貼文<a class="h-anchor" href="#%e8%a8%ad%e5%ae%9a-shortscodes-%e6%8f%92%e5%85%a5-youtube-%e5%bd%b1%e7%89%87ig-%e8%b2%bc%e6%96%87" aria-label="這個段落的連結"></a></h3>
<hr>
<p>如果想在自己的部落格插入其他社群媒體的元素，可以使用 shortscodes 的方案。</p>
<p>下面是<a href="https://gohugo.io/shortcodes/youtube/">插入 Youtube 影片</a>，以及<a href="https://gohugo.io/shortcodes/instagram/">插入 IG 貼文</a>的範例。</p>
<ul>
<li>Youtube 原始 URL: <code>https://www.youtube.com/watch?v=yVfafM70bzY</code></li>
</ul>
<div class="yt" data-yt="yVfafM70bzY" data-title="用 n8n 在 Google Sheet 自動建立 SEO 關鍵字矩陣">
  <a class="yt-link" href="https://www.youtube.com/watch?v=yVfafM70bzY" target="_blank" rel="noopener" aria-label="播放影片：用 n8n 在 Google Sheet 自動建立 SEO 關鍵字矩陣">
    <img src="https://i.ytimg.com/vi/yVfafM70bzY/hqdefault.jpg" alt="" width="480" height="360" loading="lazy" decoding="async">
    <span class="yt-play" aria-hidden="true"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"><path d="M8 5.2v13.6L19 12z"/></svg></span>
    <span class="yt-title">用 n8n 在 Google Sheet 自動建立 SEO 關鍵字矩陣</span>
  </a>
</div>

<ul>
<li>IG 原始 URL: <code>https://www.instagram.com/p/Cu9zfv0vMoR/</code></li>
</ul>
<blockquote
    class="instagram-media"
    data-instgrm-captioned
    data-instgrm-permalink="https://www.instagram.com/p/Cu9zfv0vMoR"
    data-instgrm-version="14"
    style="
      background: #fff;
      border: 0;
      border-radius: 3px;
      box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.5), 0 1px 10px 0 rgba(0, 0, 0, 0.15);
      margin: 1px;
      max-width: 540px;
      min-width: 326px;
      padding: 0;
      width: 99.375%;
      width: -webkit-calc(100% - 2px);
      width: calc(100% - 2px);
    "
  >
    <div style="padding: 16px">
      <a
        href="https://www.instagram.com/p/Cu9zfv0vMoR"
        style="
          background: #ffffff;
          line-height: 0;
          padding: 0 0;
          text-align: center;
          text-decoration: none;
          width: 100%;
        "
        target="_blank"
      >
        <div style="display: flex; flex-direction: row; align-items: center">
          <div
            style="
              background-color: #f4f4f4;
              border-radius: 50%;
              flex-grow: 0;
              height: 40px;
              margin-right: 14px;
              width: 40px;
            "
          ></div>
          <div
            style="
              display: flex;
              flex-direction: column;
              flex-grow: 1;
              justify-content: center;
            "
          >
            <div
              style="
                background-color: #f4f4f4;
                border-radius: 4px;
                flex-grow: 0;
                height: 14px;
                margin-bottom: 6px;
                width: 100px;
              "
            ></div>
            <div
              style="
                background-color: #f4f4f4;
                border-radius: 4px;
                flex-grow: 0;
                height: 14px;
                width: 60px;
              "
            ></div>
          </div>
        </div>
        <div style="padding: 19% 0"></div>
        <div
          style="display: block; height: 50px; margin: 0 auto 12px; width: 50px"
        >
          <svg
            width="50px"
            height="50px"
            viewBox="0 0 60 60"
            version="1.1"
            xmlns="https://www.w3.org/2000/svg"
            xmlns:xlink="https://www.w3.org/1999/xlink"
          >
            <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
              <g transform="translate(-511.000000, -20.000000)" fill="#000000">
                <g>
                  <path
                    d="M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631"
                  ></path>
                </g>
              </g>
            </g>
          </svg>
        </div>
        <div style="padding-top: 8px">
          <div
            style="
              color: #3897f0;
              font-family: Arial, sans-serif;
              font-size: 14px;
              font-style: normal;
              font-weight: 550;
              line-height: 18px;
            "
          >
            View this post on Instagram
          </div>
        </div>
        <div style="padding: 12.5% 0"></div>
        <div
          style="
            display: flex;
            flex-direction: row;
            margin-bottom: 14px;
            align-items: center;
          "
        >
          <div>
            <div
              style="
                background-color: #f4f4f4;
                border-radius: 50%;
                height: 12.5px;
                width: 12.5px;
                transform: translateX(0px) translateY(7px);
              "
            ></div>
            <div
              style="
                background-color: #f4f4f4;
                height: 12.5px;
                transform: rotate(-45deg) translateX(3px) translateY(1px);
                width: 12.5px;
                flex-grow: 0;
                margin-right: 14px;
                margin-left: 2px;
              "
            ></div>
            <div
              style="
                background-color: #f4f4f4;
                border-radius: 50%;
                height: 12.5px;
                width: 12.5px;
                transform: translateX(9px) translateY(-18px);
              "
            ></div>
          </div>
          <div style="margin-left: 8px">
            <div
              style="
                background-color: #f4f4f4;
                border-radius: 50%;
                flex-grow: 0;
                height: 20px;
                width: 20px;
              "
            ></div>
            <div
              style="
                width: 0;
                height: 0;
                border-top: 2px solid transparent;
                border-left: 6px solid #f4f4f4;
                border-bottom: 2px solid transparent;
                transform: translateX(16px) translateY(-4px) rotate(30deg);
              "
            ></div>
          </div>
          <div style="margin-left: auto">
            <div
              style="
                width: 0px;
                border-top: 8px solid #f4f4f4;
                border-right: 8px solid transparent;
                transform: translateY(16px);
              "
            ></div>
            <div
              style="
                background-color: #f4f4f4;
                flex-grow: 0;
                height: 12px;
                width: 16px;
                transform: translateY(-4px);
              "
            ></div>
            <div
              style="
                width: 0;
                height: 0;
                border-top: 8px solid #f4f4f4;
                border-left: 8px solid transparent;
                transform: translateY(-4px) translateX(8px);
              "
            ></div>
          </div>
        </div>
        <div
          style="
            display: flex;
            flex-direction: column;
            flex-grow: 1;
            justify-content: center;
            margin-bottom: 24px;
          "
        >
          <div
            style="
              background-color: #f4f4f4;
              border-radius: 4px;
              flex-grow: 0;
              height: 14px;
              margin-bottom: 6px;
              width: 224px;
            "
          ></div>
          <div
            style="
              background-color: #f4f4f4;
              border-radius: 4px;
              flex-grow: 0;
              height: 14px;
              width: 144px;
            "
          ></div></div
      ></a>
    </div>
  </blockquote><script async src="https://www.instagram.com/embed.js"></script>
<h3 id="用-chatgpt-生成建議的英文檔名使用年月作為資料夾結構">用 ChatGPT 生成建議的英文檔名，使用「年月」作為資料夾結構<a class="h-anchor" href="#%e7%94%a8-chatgpt-%e7%94%9f%e6%88%90%e5%bb%ba%e8%ad%b0%e7%9a%84%e8%8b%b1%e6%96%87%e6%aa%94%e5%90%8d%e4%bd%bf%e7%94%a8%e5%b9%b4%e6%9c%88%e4%bd%9c%e7%82%ba%e8%b3%87%e6%96%99%e5%a4%be%e7%b5%90%e6%a7%8b" aria-label="這個段落的連結"></a></h3>
<hr>
<p>Hugo 會使用 Markdown 文件的檔名作為網址，如果使用中文命名，那網址就會變得很長。</p>
<p>比如複製這段網址:「http://localhost:1313/blog/中文的網址」，貼上時就會因為編碼變成一長串無法辨識的字「http://localhost:1313/blog/%E4%B8%AD%E6%96%87%E7%9A%84%E7%B6%B2%E5%9D%80/」</p>
<p>如果不知道這篇文章的英文檔名如何取，可以用下面的 Prompt，請 ChatGPT 幫你一把。</p>
<pre tabindex="0"><code>幫我將下面的文章標題轉為簡短易懂的英文檔名，單字間使用「-」作為區隔:
1. 挑選合適的主題，在本地安裝並啟動 Hugo
2. 設定 Hugo 部落格網站的基礎參數（自我介紹、圖片、網站 Logo、Email、社群媒體...）
3. 在 Hugo 用 Markdown 撰寫第一篇文章，掌握分類、標籤文章的技巧
</code></pre><p><img src="https://deanlin.net/images/post/202501/hugo3-write-first-post-hugo-markdown-tags/chatGPT_hu_84c0c5f9a48e582f.webp" width="1440" height="819" alt="ChatGPT 將三篇文章標題轉成英文檔名的對話" loading="lazy" decoding="async"></p>
<p>另外 <code>content</code> 底下的文章，我建議使用「年月」的方式作為資料夾，比如「202501」。因為文章分類的部分，在「categories、tags」已經有設計了，用年月的結構，反而更容易檢視自己發文的頻率。</p>
<p>另外放置部落格圖片的 <code>assets/images</code> 也是一樣的道理，建議使用「年月/文章檔名」的結構來做存放，這樣更方便管理。</p>
<p><strong>重點：網址的結構在一開始就要決定好，因為網址就像是身分證；一但調整，過去累積的 SEO 就會歸零。</strong></p>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<hr>
<p>這邊先恭喜大家完成部落格網站的雛形，下一篇文章會帶大家<a href="https://deanlin.net/blog/202501/hugo4-deploy-hugo-github-pages-add-google-analytics/">將網站部署到 GitHub Pages</a>，完成這個步驟後，就可以把漂亮的網站分享給朋友了！</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>[Hugo自架站-2]設定部落格網站的基礎參數（自我介紹、圖片、網站 Logo、Email、社群媒體...）</title>
      <link>https://deanlin.net/blog/202501/hugo2-setup-hugo-site-parameters/</link>
      <pubDate>Fri, 17 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo2-setup-hugo-site-parameters/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>這篇文章將帶你完成 Hugo 網站的基礎設定，包括安裝 VSCode 外掛、調整網站參數、自訂 Logo 與菜單 Menu 等實用技巧，帶你一步步打造更符合個人風格的網站！</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/cover_hu_80f88b290cf62352.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/cover_hu_eb1e294171a51fc3.webp" width="1031" height="508" alt="〈設定部落格網站的基礎參數〉封面" fetchpriority="high" decoding="async"></p>
<p>如果還沒安裝好 Hugo 的朋友，可以參考上一篇文章「<a href="https://deanlin.net/blog/202501/hugo1-choose-theme-install-start-hugo/">挑選合適的主題，在本地安裝並啟動 Hugo</a>」</p>
<p>這篇文章將帶你完成 Hugo 網站的基礎設定，包括安裝 VSCode 外掛、調整網站參數、自訂 Logo 與菜單 Menu 等實用技巧，帶你一步步打造更符合個人風格的網站！</p>
<h3 id="安裝-vscode-外掛extension">安裝 VSCode 外掛（Extension）<a class="h-anchor" href="#%e5%ae%89%e8%a3%9d-vscode-%e5%a4%96%e6%8e%9bextension" aria-label="這個段落的連結"></a></h3>
<hr>
<p>Hugo 的基礎設定，大多都在附檔名為「.toml」的設定檔中調整。但預設的字體顏色都一樣，這會增加閱讀與編輯的難度。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/toml_hu_d765a7651c4c2166.webp" width="1440" height="693" alt="VS Code 中尚未語法上色的 hugo.toml" loading="lazy" decoding="async"></p>
<p>建議讀者可以先去 VSCode 的「Extension」搜尋「Toml」，然後找一個使用量最高的外掛來安裝。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/toml2_hu_7732547d496747e1.webp" width="1440" height="503" alt="VS Code 延伸模組 Even Better TOML" loading="lazy" decoding="async"></p>
<p>安裝完畢後，附檔名為「.toml」檔案的都有分色了。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/toml3_hu_72128814cd36925e.webp" width="1440" height="693" alt="安裝外掛後 hugo.toml 已有語法上色" loading="lazy" decoding="async"></p>
<h3 id="調整網頁的網址名稱">調整網頁的網址、名稱<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4%e7%b6%b2%e9%a0%81%e7%9a%84%e7%b6%b2%e5%9d%80%e5%90%8d%e7%a8%b1" aria-label="這個段落的連結"></a></h3>
<hr>
<p>打開「config/_default/hugo.toml」，將下面的參數調整成自己的：</p>
<ul>
<li><strong>baseURL</strong>: 放上自己 Github 的網址，ex: <a href="https://xxx.github.io">https://xxx.github.io</a></li>
<li><strong>languageCode</strong>: 原本是英文，我調整為中文（zh-tw）</li>
<li><strong>title</strong>: 調整為自己的網頁名稱，ex: 林鼎淵</li>
</ul>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/hugo_default_hu_64a438a2030dd478.webp" width="1440" height="440" alt="hugo.toml 中設定網站網址、語系與標題" loading="lazy" decoding="async"></p>
<p>調整完後重啟 Hugo，因為在 Local 開發，因此進入的網址會變成「http://localhost:1313」，且網頁上面名稱改變。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/hugo_default2_hu_ea80f74aceb6ee6f.webp" width="1194" height="372" alt="瀏覽器分頁標題顯示網站名稱林鼎淵" loading="lazy" decoding="async"></p>
<h3 id="將-logo作者名稱email-調整成自己的">將 Logo、作者名稱、Email 調整成自己的<a class="h-anchor" href="#%e5%b0%87-logo%e4%bd%9c%e8%80%85%e5%90%8d%e7%a8%b1email-%e8%aa%bf%e6%95%b4%e6%88%90%e8%87%aa%e5%b7%b1%e7%9a%84" aria-label="這個段落的連結"></a></h3>
<hr>
<p>打開「hugo.toml」，搜尋「default parameters」，將下面的參數調整成自己的：</p>
<ul>
<li><strong>logo</strong>: Hugo 圖片默認放在「assets」資料夾下，到「assets/images/logo.png」，將 logo.png 替換成自己的。</li>
<li><strong>author</strong>: 填上自己的名字，ex: 林鼎淵</li>
<li><strong>description</strong>: 這是網址時，網頁預覽會出現的文字描述，你可以簡述這個部落格會分享的內容</li>
<li><strong>email</strong>: 放上自己的聯絡資訊</li>
</ul>
<p>另外我這邊將「mobile、location」註解了。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/hugo_toml_hu_a737911b1bc19e95.webp" width="1440" height="624" alt="hugo.toml 中設定網站描述、作者與 Email" loading="lazy" decoding="async"></p>
<p>接著搜尋「social site」的區塊，你可以在「link」放上想要導流的社群媒體連結，而不需要的直接移除就好（我僅保留 Facebook、GitHub、Linkedin）。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/hugo_toml2_hu_cb7e4126b26791aa.webp" width="1440" height="800" alt="hugo.toml 的 social 區塊設定社群連結" loading="lazy" decoding="async"></p>
<p>調整完後，點擊「Contact」可以看到剛剛的調整。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/hugo_toml3_hu_a6561267ae5c4870.webp" width="1440" height="616" alt="Contact 頁顯示新的 Logo、社群圖示與 Email" loading="lazy" decoding="async"></p>
<h3 id="關閉-newsletter-的功能">關閉 Newsletter 的功能<a class="h-anchor" href="#%e9%97%9c%e9%96%89-newsletter-%e7%9a%84%e5%8a%9f%e8%83%bd" aria-label="這個段落的連結"></a></h3>
<hr>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/newsletter_hu_598aa06580436121.webp" width="1440" height="764" alt="Join Our Newsletter 電子報訂閱區塊" loading="lazy" decoding="async"></p>
<p>Newsletter 是提供使用者訂閱的功能，而這個功能需要與資料庫串接，而靜態網站並沒有資料庫，所以我們要關閉這個功能。</p>
<p>打開「hugo.toml」，搜尋「news letter」，把 enable 變成 false</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/newsletter2_hu_481d0e07cb78e9a0.webp" width="1440" height="291" alt="hugo.toml 中關閉 newsletter 的設定" loading="lazy" decoding="async"></p>
<p>回到剛剛的頁面，就會發現「Newsletter」的區塊移除了。</p>
<h3 id="調整語言資料夾">調整語言資料夾<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4%e8%aa%9e%e8%a8%80%e8%b3%87%e6%96%99%e5%a4%be" aria-label="這個段落的連結"></a></h3>
<hr>
<p>打開「config/_default/languages.toml」，你會發現 Hugo 預設有多國語言的設計，一開始默認文章放在「content/english」底下。</p>
<p>你可以沿用這個多國語言的設計，但筆者估計自己沒有這麼多的心力，所以把 contentDir 的「english」這層直接移除了；並將 languageCode 調整為「zh-tw」，設定如下：</p>
<pre tabindex="0"><code># --------------------------
# English language
# --------------------------
[en]
languageName = &#34;En&#34;
languageCode = &#34;zh-tw&#34;
contentDir = &#34;content&#34;
weight = 1
</code></pre><h3 id="調整自我介紹的內容about-me">調整自我介紹的內容（About Me）<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4%e8%87%aa%e6%88%91%e4%bb%8b%e7%b4%b9%e7%9a%84%e5%85%a7%e5%ae%b9about-me" aria-label="這個段落的連結"></a></h3>
<hr>
<p>因為我們上一步將「english」這層資料夾移除，所以要把下面的資料往「content」移，這樣相對路徑才能順利抓到檔案。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/content_hu_a97e7b15a996b313.webp" width="788" height="992" alt="移除 english 層後的 content 資料夾結構" loading="lazy" decoding="async"></p>
<p>接著打開「content/about/_index.md」，調整下面的設定：</p>
<ul>
<li><strong>image</strong>: 到「assets/images/author.png」，將 author.png 替換成自己的。</li>
<li><strong>description</strong>: 這是網頁預覽時會出現的文字描述。</li>
<li>把最下方的文字調整成自己的自我介紹。</li>
</ul>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/content2_hu_8f2864990d3fae89.webp" width="1440" height="837" alt="About 頁設定檔中的頭像、描述與自我介紹" loading="lazy" decoding="async"></p>
<p>調整完後，點擊「About」可以看到剛剛的調整。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/content3_hu_382daba3fbdea142.webp" width="1440" height="871" alt="About Me 頁面顯示更新後的頭像與自我介紹" loading="lazy" decoding="async"></p>
<h3 id="調整-or-隱藏自我介紹下方的-my-gallery-相簿集">調整 or 隱藏自我介紹下方的 My Gallery 相簿集<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4-or-%e9%9a%b1%e8%97%8f%e8%87%aa%e6%88%91%e4%bb%8b%e7%b4%b9%e4%b8%8b%e6%96%b9%e7%9a%84-my-gallery-%e7%9b%b8%e7%b0%bf%e9%9b%86" aria-label="這個段落的連結"></a></h3>
<hr>
<p>自我介紹下的「My Gallery」設定路徑在「data/gallery.yml」，你可以將裡面的照片調成為自己的宣傳照，或是將 enable 改為 false 來隱藏這個區塊。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/gallery_hu_356cde280989be04.webp" width="1318" height="964" alt="gallery.yml 的 enable 開關與相簿圖片清單" loading="lazy" decoding="async"></p>
<h3 id="調整移除不需要的菜單menu">調整、移除不需要的菜單（Menu）<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4%e7%a7%bb%e9%99%a4%e4%b8%8d%e9%9c%80%e8%a6%81%e7%9a%84%e8%8f%9c%e5%96%aemenu" aria-label="這個段落的連結"></a></h3>
<hr>
<p>打開「config/_default/menus.en.toml」後，會看到設定會分成 main 跟 footer 兩塊：</p>
<ul>
<li><strong>name</strong>: 網頁顯示的名稱</li>
<li><strong>URL</strong>: 網頁的路徑</li>
<li><strong>weight</strong>: 排序權重（從左到右）</li>
</ul>
<p>這邊我就將 main menu 調整如下（移除 contact、name 改為中文、weight 調整）:</p>
<pre tabindex="0"><code># main menu
[[main]]
name = &#34;關於我&#34;
URL = &#34;about/&#34;
weight = 2

[[main]]
name = &#34;文章&#34;
URL = &#34;blog/&#34;
weight = 1
</code></pre><p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/header_hu_8aa795195720d236.webp" width="1440" height="147" alt="頁首選單改為中文的文章與關於我" loading="lazy" decoding="async"></p>
<h3 id="調整網頁的-logo">調整網頁的 Logo<a class="h-anchor" href="#%e8%aa%bf%e6%95%b4%e7%b6%b2%e9%a0%81%e7%9a%84-logo" aria-label="這個段落的連結"></a></h3>
<p>如果想使用自己的 Logo，可以輸入以下指令建立對應的靜態文件資料夾：</p>
<pre tabindex="0"><code>mkdir static/images
</code></pre><p>然後在裡面放上自己的「favicon.png」就好了，<strong>Logo 僅能用「.png」的檔案喔</strong>！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo2-setup-hugo-site-parameters/favicon_hu_774dc0ed09bbab9a.webp" width="804" height="344" alt="瀏覽器分頁顯示自訂的 favicon 圖示" loading="lazy" decoding="async"></p>
<blockquote>
<p>如果發現刷新沒有反應，可能是因為 Cache 問題，<a href="https://chromewebstore.google.com/detail/clear-cache/cppjkneekbjaeellbfkmgnhonkkjfpdn?hl=zh-TW&amp;sid=h32QM2">安裝 Chrome 外掛 Clear Cache 能有效解決</a>。</p>
</blockquote>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<hr>
<p>成功將網站資訊調整為自己的後，下一步就要開始準備發表文章了。</p>
<p>Hugo 是使用 Markdown 語法來撰寫文章。下一篇文章將跟大家分享如何<a href="https://deanlin.net/blog/202501/hugo3-write-first-post-hugo-markdown-tags/">用 Markdown 撰寫文章，並掌握分類、標籤文章的技巧</a>。</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>[Hugo自架站-1]挑選合適的主題，在本地安裝並啟動 Hugo</title>
      <link>https://deanlin.net/blog/202501/hugo1-choose-theme-install-start-hugo/</link>
      <pubDate>Thu, 16 Jan 2025 22:07:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202501/hugo1-choose-theme-install-start-hugo/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>如果你跟筆者一樣選擇用靜態網站來經營個人品牌，強烈建議收藏這系列用 Hugo 架站的文章。我會從挑選主題、安裝 Hugo 開始，一步步帶你客製化網頁參數，最終將網站部署到 GitHub Pages，並加上 Google Analitycs 來追蹤流量！</description>
      <media:content url="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/cover_hu_cba5eee478372f20.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/cover_hu_5ed483b49ca44ca2.webp" width="1440" height="765" alt="〈挑選合適的主題，在本地安裝並啟動 Hugo〉封面" fetchpriority="high" decoding="async"></p>
<p>如果你跟筆者一樣選擇用靜態網站來經營個人品牌，強烈建議收藏這系列用 Hugo 架站的文章。我會從挑選主題、安裝 Hugo 開始，一步步帶你客製化網頁參數，最終將網站部署到 GitHub Pages，並加上 Google Analitycs 來追蹤流量！</p>
<h3 id="什麼是-github-pages">什麼是 GitHub Pages？<a class="h-anchor" href="#%e4%bb%80%e9%ba%bc%e6%98%af-github-pages" aria-label="這個段落的連結"></a></h3>
<hr>
<p><a href="https://github.com/">GitHub</a> 是一個程式碼版本控制的平台，而 GitHub Pages 則是它的一個副產物。</p>
<p>如果你上傳一個副檔名為「.html」的檔案，GitHub Pages 就會把它轉換成漂亮的網頁，並且這個網頁是可以透過 Google 搜尋找到的。</p>
<p>如果你是程式小白也不用擔心，因為筆者接下來會帶大家會「Hugo」這個工具，來產生個人品牌網站的 html 程式碼。</p>
<h3 id="什麼是-hugo">什麼是 Hugo？<a class="h-anchor" href="#%e4%bb%80%e9%ba%bc%e6%98%af-hugo" aria-label="這個段落的連結"></a></h3>
<hr>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/office_website_hu_7f0f9297d5b1b912.webp" width="1440" height="768" alt="Hugo 官網首頁標語：全球最快的網站建置框架" loading="lazy" decoding="async"></p>
<p>「The world’s fastest framework for building websites」</p>
<p>進入 <a href="https://gohugo.io/">Hugo 官網</a>後，你會看到這段宣傳標語，它號稱自己是<strong>全世界最快的個人網站架設工具</strong>。</p>
<h3 id="挑選自己喜歡的主題theme">挑選自己喜歡的主題（Theme）<a class="h-anchor" href="#%e6%8c%91%e9%81%b8%e8%87%aa%e5%b7%b1%e5%96%9c%e6%ad%a1%e7%9a%84%e4%b8%bb%e9%a1%8ctheme" aria-label="這個段落的連結"></a></h3>
<hr>
<p>Hugo 有提供豐富的主題供大家選擇，大家只要點擊「Themes」便可瀏覽各主題的預覽圖。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/themes_hu_97ee7bac8085bf09.webp" width="1440" height="768" alt="Hugo 官方網站的 Themes 主題列表" loading="lazy" decoding="async"></p>
<p>因為筆者的目標是建立個人品牌的部落格，所以選擇旁邊「Blog」的分類，然後就可以像是逛街般挑選自己喜歡的主題了。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/blog_hu_f79d9e87c13e3567.webp" width="1440" height="768" alt="Hugo Themes 以 Blog 標籤篩選的主題列表" loading="lazy" decoding="async"></p>
<p>看到心儀的主題後，在下載（Download）前，你可以先往下滑。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/download_hu_253c2391ae7e43dd.webp" width="1440" height="768" alt="Stack 主題的介紹頁與 Download 按鈕" loading="lazy" decoding="async"></p>
<p>部分的主題有提供 Demo，可以觀看<a href="https://demo.stack.jimmycai.com/">這個網站</a>具體呈現的效果如何。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/demo_url_hu_fdc7fd13032c7da8.webp" width="1440" height="768" alt="Stack 主題說明文件中的 Demo 網址" loading="lazy" decoding="async"></p>
<p>因為對個人品牌來說，「文章」是最大重點，所以可以多關注「封面、文字、圖片、程式碼、目錄、標題」等資訊呈現的方式。</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/demo_hu_2618f9a1068017a8.webp" width="1440" height="768" alt="Stack 主題 Demo 首頁的側欄與文章卡片" loading="lazy" decoding="async"></p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/article_hu_e1f3d3aae025ac26.webp" width="1440" height="768" alt="Stack 主題 Demo 的文章頁，含程式碼區塊與目錄" loading="lazy" decoding="async"></p>
<blockquote>
<p>因為挑來挑去沒找到合適的，所以筆者選擇了跟<a href="https://hahow.in/courses/5de8fec16117240026540b9c">古古課程</a>相同的主題（<a href="https://github.com/gethugothemes/liva-hugo">liva</a>）。</p>
</blockquote>
<h3 id="安裝-hugo從零開始建立自己的個人網站">安裝 Hugo，從零開始建立自己的個人網站<a class="h-anchor" href="#%e5%ae%89%e8%a3%9d-hugo%e5%be%9e%e9%9b%b6%e9%96%8b%e5%a7%8b%e5%bb%ba%e7%ab%8b%e8%87%aa%e5%b7%b1%e7%9a%84%e5%80%8b%e4%ba%ba%e7%b6%b2%e7%ab%99" aria-label="這個段落的連結"></a></h3>
<hr>
<p>下面的操作步驟為 <a href="https://gohugo.io/installation/macos/">Mac 環境</a>，使用 Windows 的朋友請參考<a href="https://gohugo.io/installation/windows/">官方文件的操作步驟</a></p>
<p><strong>STEP 1</strong>：打開終端機（Terminal）。</p>
<p><strong>STEP 2</strong>：安裝 <a href="https://brew.sh/">Homebrew</a></p>
<pre tabindex="0"><code>/bin/bash -c &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&#34;
</code></pre><p><strong>STEP 3</strong>：用 Homebrew 安裝 Hugo</p>
<pre tabindex="0"><code>brew install hugo
</code></pre><p>安裝完成後，輸入 <code>hugo version</code> 確認自己有順利安裝</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/hugoversion_hu_d01eb7512b5723fb.webp" width="1440" height="170" alt="終端機執行 hugo version 顯示版本號" loading="lazy" decoding="async"></p>
<p><strong>STEP 4</strong>：安裝 Hugo 的 liva 主題</p>
<pre tabindex="0"><code>git clone https://github.com/gethugothemes/liva-hugo.git
</code></pre><p><strong>STEP 5</strong>：調整資料夾結構，並建立放置主題的 themes 資料夾</p>
<pre tabindex="0"><code>mv liva-hugo/exampleSite brandSite
mkdir brandSite/themes
mv liva-hugo brandSite/themes
</code></pre><h3 id="啟動-hugo">啟動 Hugo<a class="h-anchor" href="#%e5%95%9f%e5%8b%95-hugo" aria-label="這個段落的連結"></a></h3>
<hr>
<p>執行下面指令就可啟動 Hugo</p>
<pre tabindex="0"><code>cd brandSite
hugo server
</code></pre><p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/run_hugo_hu_6a0dd120367fd638.webp" width="1440" height="725" alt="終端機執行 hugo server 並顯示本機網址" loading="lazy" decoding="async"></p>
<p>進入 http://localhost:1313/liva/examplesite/ ，如果看到下面的畫面，就恭喜你成功嚕（想關閉用 Ctrl + C 即可）！</p>
<p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/hugo_init_hu_425ab1d7addc1654.webp" width="1440" height="881" alt="在本機成功啟動的 liva 主題範例網站" loading="lazy" decoding="async"></p>
<h3 id="排除-hugo-啟動時的錯誤">排除 Hugo 啟動時的錯誤<a class="h-anchor" href="#%e6%8e%92%e9%99%a4-hugo-%e5%95%9f%e5%8b%95%e6%99%82%e7%9a%84%e9%8c%af%e8%aa%a4" aria-label="這個段落的連結"></a></h3>
<hr>
<p>但如果讀者遇到這段錯誤也不要害怕：「Error: command error: failed to load modules: failed to download modules: binary with name &ldquo;go&rdquo; not found in PATH」，安裝 Go 即可。</p>
<pre tabindex="0"><code>brew install go
</code></pre><p><img src="https://deanlin.net/images/post/202501/hugo1-choose-theme-install-start-hugo/error_hu_b5e80c506a0cdc15.webp" width="1440" height="241" alt="hugo server 找不到 go 的錯誤與安裝指令" loading="lazy" decoding="async"></p>
<h3 id="結語">結語<a class="h-anchor" href="#%e7%b5%90%e8%aa%9e" aria-label="這個段落的連結"></a></h3>
<p>做到這邊就完成 Hugo 的初始化了，但現在網頁的內容都是主題預設的；筆者會在<a href="https://deanlin.net/blog/202501/hugo2-setup-hugo-site-parameters/">下一篇文章分享設定部落格網站的基礎參數（自我介紹、圖片、網站 Logo、Email、社群媒體&hellip;）的技巧</a>。</p>
<p>在文章的最後，要特別感謝<a href="https://www.facebook.com/kucw.io">古古的後端筆記</a>，許多操作步驟與設計邏輯，筆者都是參考她在 Hahow 開設的「<a href="https://hahow.in/courses/5de8fec16117240026540b9c">Github 免費架站術！輕鬆打造個人品牌</a>」這堂課，如果想知道更詳細的操作細節，歡迎到 Hahow 上支持選購。</p>
<hr>
<blockquote>
<p>我是林鼎淵，如果覺得這邊文章對你有幫助，歡迎追蹤筆者的 <a href="https://www.facebook.com/deanlinbao">Facebook</a> 與 <a href="https://www.youtube.com/@dlcorner">YouTube</a>，我會持續分享實用的新知識 💡</p>
</blockquote>
]]></content:encoded>
    </item>
  </channel>
</rss>
