<?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>双端同步 on Ningfeiyu</title>
    <link>https://ningop.com/tags/%E5%8F%8C%E7%AB%AF%E5%90%8C%E6%AD%A5/</link>
    <description>Recent content in 双端同步 on Ningfeiyu</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sun, 14 Jun 2026 00:00:00 +0800</lastBuildDate>
    <atom:link href="https://ningop.com/tags/%E5%8F%8C%E7%AB%AF%E5%90%8C%E6%AD%A5/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Hugo 双端同步部署：GitHub Pages &#43; srht.site 完整实操</title>
      <link>https://ningop.com/posts/hugo-dual-deploy-github-srht/</link>
      <pubDate>Sun, 14 Jun 2026 00:00:00 +0800</pubDate>
      <guid>https://ningop.com/posts/hugo-dual-deploy-github-srht/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;Dual Deploy&#34; loading=&#34;lazy&#34; src=&#34;https://ningop.com/images/Dual_Deploy_1b74da0189ea.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;问题背景&lt;/strong&gt;：同一套 Hugo 源码，想同时部署到：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;源站&lt;/strong&gt;：&lt;code&gt;https://ningfeiyu.github.io&lt;/code&gt; (GitHub Pages)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;镜像站&lt;/strong&gt;：&lt;code&gt;https://ninq.srht.site&lt;/code&gt; (sr.ht Pages)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;核心痛点：&lt;strong&gt;&lt;code&gt;baseURL&lt;/code&gt; 冲突&lt;/strong&gt; —— 构建时写死哪个域名，另一端的所有绝对链接（导航、canonical、sitemap、资源引用）就会指错。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;根因分析&#34;&gt;根因分析&lt;/h2&gt;
&lt;p&gt;Hugo 在构建时会把 &lt;code&gt;baseURL&lt;/code&gt; 注入到：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;导航菜单 &lt;code&gt;&amp;lt;a href=&amp;quot;https://baseURL/posts/&amp;quot;&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Canonical 标签 &lt;code&gt;&amp;lt;link rel=&amp;quot;canonical&amp;quot; href=&amp;quot;https://baseURL/...&amp;quot;&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Sitemap &lt;code&gt;&amp;lt;loc&amp;gt;https://baseURL/...&amp;lt;/loc&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;部分主题内置的绝对资源链接&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;若只用一个 &lt;code&gt;hugo.toml&lt;/code&gt;，双端必有一端链接错指。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;解决方案双配置--独立构建目录&#34;&gt;解决方案：双配置 + 独立构建目录&lt;/h2&gt;
&lt;h3 id=&#34;1-目录结构&#34;&gt;1. 目录结构&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ningfeiyu.github.io/
├── hugo.toml              # 主配置：baseURL = &amp;#34;https://ningfeiyu.github.io/&amp;#34;
├── hugo.srht.toml         # 镜像配置：baseURL = &amp;#34;https://ninq.srht.site/&amp;#34; + relativeURLs = true
├── content/
├── themes/PaperMod/       # 已内置主题（非 submodule）
├── public/                # GitHub Pages 产物
└── public_srht/           # srht.site 产物
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;2-两份配置文件&#34;&gt;2. 两份配置文件&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;hugo.toml&lt;/code&gt;（GitHub Pages 版）&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
