<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Hugo | Democratizing Data</title><link>https://b94feae1.chezo-uno.pages.dev/tags/hugo/</link><atom:link href="https://b94feae1.chezo-uno.pages.dev/tags/hugo/index.xml" rel="self" type="application/rss+xml"/><description>Hugo</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><copyright>© Aki Ariga 2017-2025</copyright><lastBuildDate>Fri, 16 Dec 2022 17:23:22 -0800</lastBuildDate><image><url>https://b94feae1.chezo-uno.pages.dev/media/icon_hu_9ca82a90e0d162db.png</url><title>Hugo</title><link>https://b94feae1.chezo-uno.pages.dev/tags/hugo/</link></image><item><title>Wowchemyをv5.5.0からv5.7.0に上げた</title><link>https://b94feae1.chezo-uno.pages.dev/post/2022-12-16-bump-wowchemy-v570/</link><pubDate>Fri, 16 Dec 2022 17:23:22 -0800</pubDate><guid>https://b94feae1.chezo-uno.pages.dev/post/2022-12-16-bump-wowchemy-v570/</guid><description>&lt;p>毎年アドベントカレンダーの時期にHugoのテーマであるWowchemy (旧 Academic) のバージョンを上げています。&lt;/p>
&lt;p>今年は、唯一参加したアドベントカレンダーもNotionで済ませてしまったので、恩恵にはあずかれませんでしたが、それでもまあ定期アップデートは大事ですね。&lt;/p>
&lt;p>Wowchemyは、スタートするときはサクッとstarter kitから作成できるのですが、変更に追従し続けるのが結構厄介で破壊的変更をガンガン入れてきます。が、ドキュメントは最新のバージョンのものしかなく、 Release noteを見てあとはソースコードを見る羽目になります。正直面倒くさい。&lt;/p>
&lt;p>というわけで、今回v5.5.0からv5.6.0、v5.7.0に上げたので何をしたかを備忘録的にメモしておきます。&lt;/p>
&lt;h3 id="v560">v5.6.0&lt;/h3>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/chezo.uno/pull/42" data-iframely-url="//iframely.net/owZY8PH?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js">&lt;/script>
&lt;p>v5.5.0からは結構大きな変更が入りました&lt;/p>
&lt;ul>
&lt;li>config.yaml (or toml) や params.yaml の構造が大幅に変わった
&lt;ul>
&lt;li>そのままだと検索、Gravaterなどが無効になるので注意&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>go.modの依存するmoduleパスの変更&lt;/li>
&lt;li>Algoliaを検索に使うと壊れる&lt;/li>
&lt;/ul>
&lt;p>config,params.yamlの変更は、特にどこにも記載がないのでソース読みながら根性で直していきます。特に、 “features” 系は適切に設定しないと、検索が消えたりして大惨事なのでお気をつけてください&lt;/p>
&lt;p>多分、rootの設定はいくつか間違っている気もしますが、もう諦めました。&lt;/p>
&lt;p>しかし、tomlの構造をパースするのは僕には難しいのでyamlのほうが楽かもしれませんね。&lt;/p>
&lt;p>2個目については、ローカルで試すときは例によって &lt;code>hugo mod get&lt;/code> をすればよいです。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">hugo mod get github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/v5@v5.6.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Algoliaは試してみたのですが、エラーが止まらなくて諦めました。&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/chezo.uno/pull/37" data-iframely-url="//iframely.net/ZR4gvfz?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js">&lt;/script>
&lt;h3 id="v570">v5.7.0&lt;/h3>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/chezo.uno/pull/43" data-iframely-url="//iframely.net/iruvBHp?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js">&lt;/script>
&lt;p>特に大きな影響もなくそのままいけました。過去一楽なアップグレードでした。&lt;/p>
&lt;p>&lt;code>hugo mod get&lt;/code> も6を7に変えるだけです。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">hugo mod get github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/v5@v5.7.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="algoliaを試したけど挫折した">Algoliaを試したけど挫折した&lt;/h3>
&lt;p>v5.6.0にも書いたのですが、Algoliaを試して辞めました。&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/chezo.uno/pull/41" data-iframely-url="//iframely.net/wyFUD6u?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js">&lt;/script>
&lt;p>検索自体はよさげなんですが&lt;/p>
&lt;ul>
&lt;li>Hugoの生成するindex.jsonを取り込むとMedium由来の &lt;code>--&lt;/code> みたいなハイフンが複数つながるURLが &lt;code>-&lt;/code> と一個に正規化されたperemalinkと解釈して、無限にredirectsを設定する羽目になる&lt;/li>
&lt;li>Algolia Crawlerを使うNetlify pluginがあるのですが、それを使ってinstantsearchから検索をすると検索結果が空になる&lt;/li>
&lt;/ul>
&lt;p>特に後者が致命的でした。なんか、便利そうだけど壊れてて使えないという体験がつらかったので諦めました。&lt;/p>
&lt;p>サポートに問い合わせをすればいいのかもしれませんが、もうその気力もなく…。&lt;/p>
&lt;p>また、来年Wowchemyのアップグレードをしたいと思います。&lt;/p></description></item><item><title>3 configs add recommend articles into your Hugo blog by GitHub Actions</title><link>https://b94feae1.chezo-uno.pages.dev/blog/2022-01-25_hugo-content-based-recommendation/</link><pubDate>Tue, 25 Jan 2022 19:37:52 -0800</pubDate><guid>https://b94feae1.chezo-uno.pages.dev/blog/2022-01-25_hugo-content-based-recommendation/</guid><description>&lt;p>Hugo has a feature to show keyword based related articles.&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://gohugo.io/content-management/related/" data-iframely-url="//iframely.net/q1grvUY?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>Yeah, keyword based articles might be useful, for people who can manage keyword, category, etc, constantly.
I&amp;rsquo;d love to add content based recommendation that doesn&amp;rsquo;t require to write explicit keywords by myself. Then, I found an open source named &amp;ldquo;Prelims&amp;rdquo; which is developed by &lt;a href="https://twitter.com/takuti" target="_blank" rel="noopener">takuti&lt;/a>.&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/takuti/prelims" data-iframely-url="//iframely.net/omDBVa8?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>Prelims is a post-processing tool for Front matter of Hugo/Jekyll, that is a metadata of an article.
The recommendation method which is implemented for now is classical, create a TF-IDF based word vector and find similar articles by consign similarity.&lt;/p>
&lt;p>The reason why I love Prelims is it&amp;rsquo;s simple and flexible. Post-processing of front matter doesn&amp;rsquo;t break your articles nor blog system at all. You can remove extra meta data Prelims generated whenever you want.&lt;/p>
&lt;p>Isn&amp;rsquo;t it practical, right?&lt;/p>
&lt;p>One downside of Prelims is it requires to implement Python code for tokenizing or vectorizing TF-IDF. I don&amp;rsquo;t want to bring my laptop for blog writing and wanna use Netlify CMS and iPad without having Python environment.&lt;/p>
&lt;p>So, I built a CLI tool for Prelims, named &lt;a href="https://github.com/chezou/prelims-cli" target="_blank" rel="noopener">prelims-cli&lt;/a>, which enables to add recommended articles just writing 1 configuration YAML file. It also runs with GitHub Actions.&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/prelims-cli" data-iframely-url="//iframely.net/m9C9uKt?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>The three things you need to prepare are:&lt;/p>
&lt;ol>
&lt;li>Configuration YAML file for prelims-cli. e.g., &lt;code>scripts/config/myconfig.yaml&lt;/code>&lt;/li>
&lt;li>Hugo HTML partial layout, e.g., &lt;code>layouts/partials/page_related.html&lt;/code>&lt;/li>
&lt;li>GitHub Actions workflow for prelims-cli&lt;/li>
&lt;/ol>
&lt;p>Here is the example gist what you need to write.&lt;/p>
&lt;script src="https://gist.github.com/chezou/a9cb0ab2a086b3ce9ce9bf1abbc5b347.js">&lt;/script>
&lt;p>where &lt;code>content/blog&lt;/code> is the directory for English articles and &lt;code>content/post&lt;/code> is the directory for Japanese articles.&lt;/p>
&lt;p>Putting three files enables you to show recommended articles into your Hugo blog, like the screenshot in the top of this article.&lt;/p>
&lt;p>Internally, for Japanese tokenization, it uses SudachiPy. Since &lt;code>keywords&lt;/code> prelims generates are a-bit noisy and didn&amp;rsquo;t wanted to cleanup, so I stopped using it.&lt;/p>
&lt;p>The good things I feel are, I can use my blog articles for my hobby recommendation project, and I don&amp;rsquo;t need to manage tags and categories seriously.&lt;/p>
&lt;p>You can enjoy your recommendation without having Python environment, so you can write your articles on iPad with Netlify CMS!&lt;/p></description></item><item><title>3ファイル追加してGitHub ActionsでHugoにレコメンド記事を表示する</title><link>https://b94feae1.chezo-uno.pages.dev/post/2022-01-25-hugo-content-based-recommendation/</link><pubDate>Tue, 25 Jan 2022 18:41:33 -0800</pubDate><guid>https://b94feae1.chezo-uno.pages.dev/post/2022-01-25-hugo-content-based-recommendation/</guid><description>&lt;p>こんにちは、早いものでもう40の大台が迫ってくる誕生日を迎えました。前日にブースターショットを打ったので、一日中ほとんど寝込んでいました。必要な人のために、&lt;a href="https://www.amazon.jp/hz/wishlist/ls/FH3MHL6LTE02?ref_=wl_share" target="_blank" rel="noopener">例のリスト&lt;/a>を置いておきます。&lt;/p>
&lt;p>さて、Hugoにはキーワードベースの関連記事の表示をする機能があります。&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://gohugo.io/content-management/related/" data-iframely-url="//iframely.net/q1grvUY?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>しかし、キーワードベースの関連記事も悪くはないのですが、折角なので自分で関連記事のレコメンドをしてみたくないですか？
そう思っていたら、 &lt;a href="https://twitter.com/takuti" target="_blank" rel="noopener">takuti&lt;/a> さんの Prelims というオープンソースを見つけました。&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/takuti/prelims" data-iframely-url="//iframely.net/omDBVa8?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>Prelimsは、Hugo（やJekyll）のFront matterと呼ばれるメタデータの部分にキーワードやレコメンド記事を足してくれるものになります。&lt;/p>
&lt;p>レコメンドの方式自体は、今実装されているのは古典的なTF-IDFを用いたコンテンツベースの類似文書を出してくる方式ですが、Front matterを後から処理してレコメンド記事を追加するというシンプルだけどスマートな方法に感銘を受けました。&lt;/p>
&lt;p>ただし、Prelimsはflexibilityを重視しているため、例えば日本語のtokenizerやstop wordsなどは自分で設定をする必要があります。&lt;/p>
&lt;p>このあたり、ちょっと慣れていないと難しいかなとも思ったので、&lt;a href="https://github.com/chezou/prelims-cli" target="_blank" rel="noopener">prelims-cli&lt;/a>というCLIツールを作り、config用のYAMLファイルを用意すればGitHub Actionsでrecommendできるようにしました。&lt;/p>
&lt;div class="iframely-embed">&lt;div class="iframely-responsive" style="height: 140px; padding-bottom: 0;">&lt;a href="https://github.com/chezou/prelims-cli" data-iframely-url="//iframely.net/m9C9uKt?card=small">&lt;/a>&lt;/div>&lt;/div>&lt;script async src="//iframely.net/embed.js" charset="utf-8">&lt;/script>
&lt;p>用意するものは以下の3つです。&lt;/p>
&lt;ol>
&lt;li>prelims-cli用の scripts/config/myconfig.yaml&lt;/li>
&lt;li>関連ページを表示する layouts/partials/page_related.html&lt;/li>
&lt;li>prelims-cliを実行する GitHub Actions&lt;/li>
&lt;/ol>
&lt;p>実際の例をgistに貼りました。&lt;/p>
&lt;script src="https://gist.github.com/chezou/a9cb0ab2a086b3ce9ce9bf1abbc5b347.js">&lt;/script>
&lt;p>myconfig.yaml については、 &lt;code>content/blog&lt;/code> が英語の &lt;code>content/post&lt;/code> が日本語の記事をおいている想定です。
この3つのファイルを追加すればHugoであれば関連記事が、冒頭の画像のように出てくるはずです。&lt;/p>
&lt;p>内部的には日本語のtokenizerはSuachiPyのfull辞書を使い、最も長いCモードで形態素単位を設定しています。
ただし、prelimsが生成する &lt;code>keywords&lt;/code> は少しノイジーだなと思ったので、自分のサイトでは &lt;code>recommendations&lt;/code> のみを利用しています。&lt;/p>
&lt;p>僕はものぐさなので、タグやカテゴリを豆にメンテナンスできないのですが、レコメンドのおかげで過去の関連記事のリンクも出せるので便利だと感じています。
また、自分の記事は自分の持ち物なので、それに対してレコメンドしてML的なsandboxとして遊ぶのは楽しいなと感じています。&lt;/p>
&lt;p>この環境を使うことで、Netlify CMSでの執筆等Python環境を用意することができないところでも執筆して、レコメンド記事を作成することができます。
もしよければ、 prelims を使ったレコメンドを試してみてください。&lt;/p></description></item></channel></rss>