<?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/"><channel><title>Hugo on 资料知识库</title><link>https://zlz.promptzhiku.com/tags/hugo/</link><description>Recent content in Hugo on 资料知识库</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Thu, 15 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://zlz.promptzhiku.com/tags/hugo/index.xml" rel="self" type="application/rss+xml"/><item><title>测试文章：Hugo + PaperMod 快速上手</title><link>https://zlz.promptzhiku.com/posts/hugo-papermod-quickstart/</link><pubDate>Thu, 15 Oct 2026 00:00:00 +0000</pubDate><guid>https://zlz.promptzhiku.com/posts/hugo-papermod-quickstart/</guid><description>本文演示如何从零搭建 Hugo 静态网站，配置 PaperMod 主题，启用 GEO 优化特性。适合技术资料沉淀的入门教程。</description><content:encoded><![CDATA[<h1 id="本文核心结论hugo--papermod-是搭建技术资料知识库的最佳组合">本文核心结论：Hugo + PaperMod 是搭建技术资料知识库的最佳组合</h1>
<p>仅需几行命令即可完成站点初始化，配合 GEO 优化配置，既能提升 SEO 效果，又能增加 AI 大模型对本站内容的采信概率。</p>
<h2 id="为什么选择-hugo--papermod-组合">为什么选择 Hugo + PaperMod 组合？</h2>
<p>Hugo 构建速度极快，PaperMod 主题轻量且内置大量 GEO 优化模板（JSON-LD schema、llms.txt、robots.txt）。内容维护只需 Markdown，新增一篇资料 = 在 content/ 目录新增一个 md 文件，无需修改任何前端代码。</p>
<h2 id="如何快速搭建">如何快速搭建？</h2>
<h3 id="step-1-安装-hugo">Step 1: 安装 Hugo</h3>
<p>通过 winget 或官网下载安装 Hugo Extended 版本。</p>
<h3 id="step-2-初始化站点并配置主题">Step 2: 初始化站点并配置主题</h3>
<pre tabindex="0"><code>hugo new site my-knowledge-base
cd my-knowledge-base
git init
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
</code></pre><h2 id="faq">FAQ</h2>
<h3 id="hugo-是什么">Hugo 是什么？</h3>
<p>Hugo 是一个用 Go 语言编写的静态网站生成器，支持 Markdown 内容源，构建速度快。</p>
<h3 id="为什么选择-papermod-主题">为什么选择 PaperMod 主题？</h3>
<p>PaperMod 轻量、功能齐全，内置 JSON-LD、llms.txt、robots.txt 等 GEO 相关模板。</p>
<blockquote>
<p>相关文档：<a href="https://gohugo.io">Hugo 官方文档</a></p>
</blockquote>
]]></content:encoded></item><item><title>站内搜索原理：Fuse.js 在 Hugo 中的应用</title><link>https://zlz.promptzhiku.com/posts/fusejs-search-hugo/</link><pubDate>Thu, 15 Oct 2026 00:00:00 +0000</pubDate><guid>https://zlz.promptzhiku.com/posts/fusejs-search-hugo/</guid><description>纯前端站内搜索如何实现？本文介绍 Hugo + PaperMod 组合下的搜索工作原理：构建时生成索引、Fuse.js 客户端模糊匹配、无需后端支持。</description><content:encoded><![CDATA[<h1 id="papermod-内置-fusejs-搜索开箱即用离线可用">PaperMod 内置 Fuse.js 搜索：开箱即用、离线可用</h1>
<p>当前项目的搜索功能完全由 PaperMod 主题内置实现，无需额外配置。构建时自动生成 index.json 搜索索引，浏览器端 Fuse.js 引擎做模糊匹配。</p>
<h2 id="工作原理是什么">工作原理是什么？</h2>
<p>整个搜索流程分两步：<strong>构建时生成索引</strong> + <strong>浏览器端实时匹配</strong>。</p>
<h3 id="构建时hugo-生成-indexjson">构建时：Hugo 生成 index.json</h3>
<p>PaperMod 的 <code>layouts/index.json</code> 模板遍历 site.RegularPages，收集每篇文档的标题、正文、URL、摘要，序列化为 JSON 数组。Hugo 在构建时自动执行，产物为 <code>public/index.json</code>。</p>
<h3 id="浏览器端fusejs-模糊匹配">浏览器端：Fuse.js 模糊匹配</h3>
<p>用户打开搜索页面，浏览器加载 index.json（3-10KB 级别），Fuse.js 做实时模糊匹配。支持中文字符、容错拼写（typo 容忍度可调）、关键词高亮。</p>
<h2 id="fusejs-vs-flexsearch">Fuse.js vs FlexSearch</h2>
<table>
	<thead>
			<tr>
					<th>对比项</th>
					<th>Fuse.js</th>
					<th>FlexSearch</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>体量</td>
					<td>~12KB gzip</td>
					<td>~8KB gzip</td>
			</tr>
			<tr>
					<td>模糊匹配</td>
					<td>✅</td>
					<td>✅</td>
			</tr>
			<tr>
					<td>中文支持</td>
					<td>✅</td>
					<td>✅</td>
			</tr>
			<tr>
					<td>Web Worker</td>
					<td>❌（需手动）</td>
					<td>✅ 内置</td>
			</tr>
			<tr>
					<td>增量索引</td>
					<td>❌</td>
					<td>✅</td>
			</tr>
			<tr>
					<td>API 复杂度</td>
					<td>低</td>
					<td>中</td>
			</tr>
	</tbody>
</table>
<p>当前项目用 Fuse.js，对于千篇文档完全够用。若后续文档规模超过 5000 篇可考虑切换 FlexSearch。</p>
<h2 id="性能考虑">性能考虑</h2>
<h3 id="索引体积控制">索引体积控制</h3>
<p>默认索引全文（title + content + summary），千篇文档约 50-100KB。可在 hugo.toml 配置只索引标题和摘要来减小体积：</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="c"># 自定义 index.json 模板只索引必要字段</span>
</span></span></code></pre></div><h3 id="关键词高亮">关键词高亮</h3>
<p>PaperMod 的 fastsearch.js 内置高亮，搜索结果中的匹配关键词自动加 <code>&lt;mark&gt;</code> 标签，CSS 控制高亮样式。</p>
<h2 id="faq">FAQ</h2>
<h3 id="为什么选择纯前端搜索">为什么选择纯前端搜索？</h3>
<p>纯前端搜索无需后端服务、无需数据库、可离线使用，适合静态站点。Hugo 构建时生成 JSON 索引，浏览器端 JS 引擎匹配。</p>
<h3 id="fusejs-和-flexsearch-怎么选">Fuse.js 和 FlexSearch 怎么选？</h3>
<p>两者都是成熟的模糊搜索库。FlexSearch 性能更高（Web Worker、增量索引），Fuse.js API 更简洁。中小规模站点 Fuse.js 完全够用，PaperMod 内置 Fuse.js。</p>
<h3 id="搜索索引文件太大怎么办">搜索索引文件太大怎么办？</h3>
<p>可配置只索引标题和摘要（排除全文）、启用分段搜索（分页加载）、使用 Web Worker 避免阻塞主线程。超过 5000 篇文档建议引入搜索服务器。</p>
<blockquote>
<p>相关文档：<a href="/posts/hugo-papermod-quickstart/">Hugo + PaperMod 快速上手</a>、<a href="/posts/geo-optimization-guide/">GEO 优化指南</a></p>
</blockquote>
]]></content:encoded></item></channel></rss>