<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/scripts/pretty-feed-v3.xsl" type="text/xsl"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:h="http://www.w3.org/TR/html4/"><channel><title>Hack Your Heart</title><link>https://h4cker.zip/tags/hugo/</link><description>临渊羡鱼，不如退而结网</description><generator>Hugo 0.168.0</generator><language>en</language><atom:link href="https://h4cker.zip/tags/hugo/rss.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Sat, 11 Oct 2025 14:46:14 +0800</lastBuildDate><item><title>Hugo设置新建文章自动打开编辑器</title><link>https://h4cker.zip/f692b7/</link><pubDate>Sat, 11 Oct 2025 14:46:14 +0800</pubDate><guid isPermaLink="true">https://h4cker.zip/f692b7/</guid><description/><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>以前设置过Hexo的自动打开编辑器，改用Hugo后一直手动新建文章，手动打开Typora。很麻烦。</p>
<p>但是没找到Hugo的设置方式，我就在论坛里问了，<a
  href="https://discourse.gohugo.io/u/jmooring/summary" rel="nofollow noopener noreferrer" target="_blank"
  >jmooring<span style="user-select:none"> ↗</span></a
>
 和 <a
  href="https://discourse.gohugo.io/u/irkode/summary" rel="nofollow noopener noreferrer" target="_blank"
  >irkode<span style="user-select:none"> ↗</span></a
>
 回复了我，这两位也是非常活跃于社区的开发者。</p>
<p>原提问链接：<a
  href="https://discourse.gohugo.io/t/can-we-configure-the-markdown-editor-to-automatically-open-this-file-when-creating-a-new-article/56065?u=tajangsec" rel="nofollow noopener noreferrer" target="_blank"
  >Can we configure the Markdown editor to automatically open this file when creating a new article?<span style="user-select:none"> ↗</span></a
>
</p>
<p>以Typora为例，你可以自由选择 VSCode、Obsidian 等等</p>
<p>首先你的编辑器要在环境变量里，可以通过终端直接启动。</p>
<p>然后在Hugo的配置文件中，设置编辑器：</p>
<div class="code-block highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="ln">1</span><span class="cl"><span class="nx">newContentEditor</span> <span class="p">=</span> <span class="s2">&#34;Typora&#34;</span></span></span></code></pre><span class="language ps-1 pe-3 text-sm bg-muted text-muted-foreground">toml</span><button class="copy text-muted-foreground p-1 box-content border rounded-lg bg-card" aria-label="Copy code"><div class="ready"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M15 2c.683 0 1.287.343 1.647.866l.085.134H18a2 2 0 0 1 1.995 1.85L20 5v12a5 5 0 0 1-4.783 4.995L15 22H6a2 2 0 0 1-1.995-1.85L4 20V5a2 2 0 0 1 1.85-1.995L6 3h1.268a2 2 0 0 1 1.563-.993L9 2zM7 5H6v15h9a3 3 0 0 0 3-3V5h-1a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2m5 9a1 1 0 0 1 .117 1.993L12 16H9a1 1 0 0 1-.117-1.993L9 14zm3-4a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2zm0-6H9v1h6z"></path></g></svg>
</div><div class="success hidden"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M13.586 2A2 2 0 0 1 15 2.586L19.414 7A2 2 0 0 1 20 8.414V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM12 4H6v16h12V10h-4.5A1.5 1.5 0 0 1 12 8.5zm1.59 8.657a1 1 0 0 1 1.415 1.414l-3.111 3.112a1.1 1.1 0 0 1-1.556 0l-1.343-1.344a1 1 0 0 1 1.414-1.414l.707.707ZM14 4.414V8h3.586z"></path></g></svg>
</div></button></div>
<p>这个配置是根级别设置，必须在所有分层配置之前，就是在那种中括号（ [、] ）包裹的配置之前。</p>
<p>然后Hugo是不能随便启动用户文件的，他有<a
  href="https://gohugo.io/configuration/security/" rel="nofollow noopener noreferrer" target="_blank"
  >安全策略<span style="user-select:none"> ↗</span></a
>
，需要加白编辑器：</p>
<div class="code-block highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="ln">1</span><span class="cl"><span class="p">[</span><span class="nx">security</span><span class="p">.</span><span class="nx">exec</span><span class="p">]</span>
</span></span><span class="line"><span class="ln">2</span><span class="cl">    <span class="nx">allow</span> <span class="p">=</span> <span class="p">[</span><span class="s1">&#39;^(dart-)?sass(-embedded)?$&#39;</span><span class="p">,</span> <span class="s1">&#39;^go$&#39;</span><span class="p">,</span> <span class="s1">&#39;^git$&#39;</span><span class="p">,</span> <span class="s1">&#39;^npx$&#39;</span><span class="p">,</span> <span class="s1">&#39;^postcss$&#39;</span><span class="p">,</span> <span class="s1">&#39;^tailwindcss$&#39;</span><span class="p">,</span><span class="s1">&#39;^[Tt]ypora$&#39;</span><span class="p">]</span></span></span></code></pre><span class="language ps-1 pe-3 text-sm bg-muted text-muted-foreground">toml</span><button class="copy text-muted-foreground p-1 box-content border rounded-lg bg-card" aria-label="Copy code"><div class="ready"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M15 2c.683 0 1.287.343 1.647.866l.085.134H18a2 2 0 0 1 1.995 1.85L20 5v12a5 5 0 0 1-4.783 4.995L15 22H6a2 2 0 0 1-1.995-1.85L4 20V5a2 2 0 0 1 1.85-1.995L6 3h1.268a2 2 0 0 1 1.563-.993L9 2zM7 5H6v15h9a3 3 0 0 0 3-3V5h-1a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2m5 9a1 1 0 0 1 .117 1.993L12 16H9a1 1 0 0 1-.117-1.993L9 14zm3-4a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2zm0-6H9v1h6z"></path></g></svg>
</div><div class="success hidden"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M13.586 2A2 2 0 0 1 15 2.586L19.414 7A2 2 0 0 1 20 8.414V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM12 4H6v16h12V10h-4.5A1.5 1.5 0 0 1 12 8.5zm1.59 8.657a1 1 0 0 1 1.415 1.414l-3.111 3.112a1.1 1.1 0 0 1-1.556 0l-1.343-1.344a1 1 0 0 1 1.414-1.414l.707.707ZM14 4.414V8h3.586z"></path></g></svg>
</div></button></div>
<p>在末尾补上编辑器即可，Hugo是大小写敏感的，所以我这个正则适用于 Typora 和 typora，两种写法。</p>
<p>前面那些是默认的，不能删掉。</p>
<p>作者也提供了不修改任何配置文件的方式，使用命令行参数：</p>
<div class="code-block highlight"><pre tabindex="0" class="chroma"><code class="language-cmd" data-lang="cmd"><span class="line"><span class="ln">1</span><span class="cl">hugo new text.md --editor Typora</span></span></code></pre><span class="language ps-1 pe-3 text-sm bg-muted text-muted-foreground">cmd</span><button class="copy text-muted-foreground p-1 box-content border rounded-lg bg-card" aria-label="Copy code"><div class="ready"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M15 2c.683 0 1.287.343 1.647.866l.085.134H18a2 2 0 0 1 1.995 1.85L20 5v12a5 5 0 0 1-4.783 4.995L15 22H6a2 2 0 0 1-1.995-1.85L4 20V5a2 2 0 0 1 1.85-1.995L6 3h1.268a2 2 0 0 1 1.563-.993L9 2zM7 5H6v15h9a3 3 0 0 0 3-3V5h-1a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2m5 9a1 1 0 0 1 .117 1.993L12 16H9a1 1 0 0 1-.117-1.993L9 14zm3-4a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2zm0-6H9v1h6z"></path></g></svg>
</div><div class="success hidden"><svg
  aria-hidden="true"
  class="pure-icon size-5"
  width="22"
  height="22"
  viewBox="0 0 24 24"
  fill="currentColor"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M13.586 2A2 2 0 0 1 15 2.586L19.414 7A2 2 0 0 1 20 8.414V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM12 4H6v16h12V10h-4.5A1.5 1.5 0 0 1 12 8.5zm1.59 8.657a1 1 0 0 1 1.415 1.414l-3.111 3.112a1.1 1.1 0 0 1-1.556 0l-1.343-1.344a1 1 0 0 1 1.414-1.414l.707.707ZM14 4.414V8h3.586z"></path></g></svg>
</div></button></div>
<p>这样就可以直接启动 Typora 编辑</p>
]]></content:encoded><category>Hugo</category></item><item><title>开发HackYourHeart主题的心路</title><link>https://h4cker.zip/4c2e74/</link><pubDate>Wed, 05 Feb 2025 20:49:22 +0800</pubDate><guid isPermaLink="true">https://h4cker.zip/4c2e74/</guid><description/><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<h1 id="hack-your-heart">Hack Your Heart<a class="anchor" href="#hack-your-heart">#</a></h1>
<p>写这个主题是因为我在Hugo的主题仓库里没有找到喜欢的主题。</p>
<p>因为我是一个<del>黑客</del>脚本小子，我想要更有黑客风格的博客，但是没找到。于是想要自己写一个博客主题。</p>
<p>由于我不会前端，写这个主题十分困难，许多HTML、CSS、JS、F12花哨调试 工具都是我现学的。这个主题也是我边学边写。</p>
<h2 id="特色">特色<a class="anchor" href="#特色">#</a></h2>
<p>没什么特色，都是一些基础功能，你能在其他主题看到相同功能。</p>
<p>许多细节真的非常难搞。搜索功能我很满意，它快速美观。代码块部分结合 Chrome 自定义效果，目录自己写的，各种公式、javascript 其中各种冲突，搞得累死我了。</p>
<p>尤其是代码块的表格显示，行号冲突，锚点冲突，又没有复制按钮。其中魔改了一个js，其中许多搞笑的bug，不过都解决了。</p>
<p>i18n还没搞</p>
<p>虽然页面布局有所借鉴，但都是我自己写的代码，代码非常烂，好在性能还行。我尽量加上了懒加载和Hugo自身的资源引用语法。性能够我自己用了。</p>
<p>首页参考Hack The Box Academy中Dashboard的 <a
  href="https://academy.hackthebox.com/modules" rel="nofollow noopener noreferrer" target="_blank"
  >Modules<span style="user-select:none"> ↗</span></a
>
 页面，色系同HTB：</p>
<p><img
  src="/4c2e74/HTB_Modules.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1187"
/>
</p>
<p>Hugo没有心目中的黑客主题，相近的大概是：<a
  href="https://hackingcapitalism.io/" rel="nofollow noopener noreferrer" target="_blank"
  >https://hackingcapitalism.io/<span style="user-select:none"> ↗</span></a
>
（二开自<a
  href="https://github.com/panr/hugo-theme-hello-friend" rel="nofollow noopener noreferrer" target="_blank"
  >hello-friend<span style="user-select:none"> ↗</span></a
>
 ），新的hello-friend-ng也不太行</p>
<p>其实 <a
  href="https://www.leavesongs.com/" rel="nofollow noopener noreferrer" target="_blank"
  >phithon<span style="user-select:none"> ↗</span></a
>
、<a
  href="https://y4tacker.github.io/" rel="nofollow noopener noreferrer" target="_blank"
  >y4tacker<span style="user-select:none"> ↗</span></a
>
，风格都不错，他们那个暗黑主题不喜欢。白色的推荐 <a
  href="https://www.ol4three.com/" rel="nofollow noopener noreferrer" target="_blank"
  >ol4three<span style="user-select:none"> ↗</span></a
>
 和 <a
  href="https://exp10it.io/" rel="nofollow noopener noreferrer" target="_blank"
  >X1r0z<span style="user-select:none"> ↗</span></a
>
</p>
<p>由于我之前使用的 hexo-theme-aurora 有大量封面图，也舍不得扔掉那么多封面。</p>
<p>其次是 <a
  href="https://3gstudent.github.io/" rel="nofollow noopener noreferrer" target="_blank"
  >3gstudent<span style="user-select:none"> ↗</span></a
>
 的，非常不错，但是感觉差了点什么，类似的最好的就是 <a
  href="https://gitlab.com/gabmus/hugo-ficurinia" rel="nofollow noopener noreferrer" target="_blank"
  >ficurinia<span style="user-select:none"> ↗</span></a
>
，真的漂亮，但我都看那么多了，不如自己搞</p>
<p>主题参考了Fixit、ficurinia等等的实现思路</p>
<p>很早以前我就喜欢HTB风格，漫画图标，酷的配色。黑客浸入感极强。比国内一些CTF、靶场好太多了。国内许多靶场就喜欢搞个普通烂大街的蓝色科技感驾驶舱大屏</p>
<p>现在不是很懂前端，大学学的三剑客貌似没啥用，于是边学边写</p>
<h3 id="主页home">主页/Home：<a class="anchor" href="#主页home">#</a></h3>
<p><img
  src="/4c2e74/hyhhome.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2700" height="1800"
/>
</p>
<h3 id="分类categories">分类/Categories：<a class="anchor" href="#分类categories">#</a></h3>
<p><img
  src="/4c2e74/hyhcategories.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="标签tags">标签/Tags：<a class="anchor" href="#标签tags">#</a></h3>
<p><img
  src="/4c2e74/hyhtags.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="存档archives">存档/Archives：<a class="anchor" href="#存档archives">#</a></h3>
<p><img
  src="/4c2e74/hyharchives.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="朋友friends">朋友/Friends：<a class="anchor" href="#朋友friends">#</a></h3>
<p><img
  src="/4c2e74/hyhfriends.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="关于about">关于/About：<a class="anchor" href="#关于about">#</a></h3>
<p>这里就是markdown直接写</p>
<p><img
  src="/4c2e74/hyhabout.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="文章post-page">文章/Post page：<a class="anchor" href="#文章post-page">#</a></h3>
<p><img
  src="/4c2e74/hyhpost.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2560" height="1229"
/>
</p>
<h3 id="代码块codeblock">代码块/Codeblock：<a class="anchor" href="#代码块codeblock">#</a></h3>
<p><img
  src="/4c2e74/hyhcodeblock.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="1537" height="1037"
/>
</p>
<h3 id="数学公式注音emojimathrubyemoji">数学公式、注音、emoji/Math、Ruby、Emoji：<a class="anchor" href="#数学公式注音emojimathrubyemoji">#</a></h3>
<p><img
  src="/4c2e74/hyhmathruby.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="1528" height="728"
/>
</p>
<h3 id="图像graph">图像/Graph：<a class="anchor" href="#图像graph">#</a></h3>
<p>goat、UML、Pie、git等等</p>
<p><img
  src="/4c2e74/hyhmermaid.webp"
  alt=""
  class="zoomable"
  loading="lazy"
  decoding="async" width="2544" height="1084"
/>
</p>
<h2 id="installation">Installation<a class="anchor" href="#installation">#</a></h2>
<p>正常安装就行。最好站点配置文件为准</p>
<blockquote>
<p>由于我许多内容都是从本地引用，所以需要额外加入字体等元素，你改成cdn引用就不用引入字体</p>
</blockquote>
<p>注意，如果要显示Katex数学公式字体正确渲染，需要把字体文件放在站点目录下的\static\lib\katex\fonts中</p>
<p>因为Katex的文件默认去所在目录引用fonts,但实际上assets里的fonts不会同步输出到public,但是static里的文件可以同步输出到public,所以你需要将fonts以相同的路径放到static里.</p>
<p>比如assets/a/b/c/katex.min.js,你就要把fonts文件夹位置调整为 static/a/b/c/fonts</p>
<p>物理化学公式需要Katex额外引入一些东西，这里不写了</p>
<p>创建带空格或特殊字符文章，用<code>hugo new &quot;posts/测试 3345.md&quot;</code></p>
<p>我为了让链接更短，使用sulg作为链接。slug生成规则是“标题|时间戳”的md5值取前6位。你嫌重复概率高可以改成8位。可以使用这个脚本为所有文章生成slug：<a
  href="https://github.com/TajangSec/genslug" rel="nofollow noopener noreferrer" target="_blank"
  >https://github.com/TajangSec/genslug<span style="user-select:none"> ↗</span></a
>
</p>
<h2 id="结语">结语<a class="anchor" href="#结语">#</a></h2>
<p>代码真的很烂，也没什么好分享的。这个主题我能一直用下去，毕竟是自己一点一点写出来的，虽然烂但是喜欢。</p>
]]></content:encoded><category>Hugo</category><category>前端</category><category>博客</category></item></channel></rss>