<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Hugo | エンジニアのひきだし</title><link>https://blog.nattokinxxxx.net/tags/hugo/</link><atom:link href="https://blog.nattokinxxxx.net/tags/hugo/index.xml" rel="self" type="application/rss+xml"/><description>Hugo</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>ja</language><copyright>© 2020 nattokinxxxx All Rights Reserved.</copyright><lastBuildDate>Wed, 22 Apr 2020 22:00:10 +0900</lastBuildDate><image><url>img/map[gravatar:%!s(bool=false) shape:circle]</url><title>Hugo</title><link>https://blog.nattokinxxxx.net/tags/hugo/</link></image><item><title>Academicテーマ（Hugo）のカスタマイズ</title><link>https://blog.nattokinxxxx.net/post/customize-academic/</link><pubDate>Wed, 22 Apr 2020 22:00:10 +0900</pubDate><guid>https://blog.nattokinxxxx.net/post/customize-academic/</guid><description>&lt;p>Academicのカスタマイズでやったことを備忘録。&lt;/p>
&lt;h2 id="authorの編集">Authorの編集&lt;/h2>
&lt;p>&lt;code>content/authors/admin/&lt;/code> を &lt;code>content/authors/{ユーザー名}/&lt;/code> に変更して&lt;/p>
&lt;ul>
&lt;li>&lt;code>_index.md&lt;/code> を編集する。&lt;/li>
&lt;li>&lt;code>avatar.jpg&lt;/code> にアイコン画像を設定&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-diff"># 表示名
&amp;lt; name: Nelson Bighetti
---
&amp;gt; name: nattokinxxxx
# フォルダ名と同じ
authors:
&amp;lt; - admin
---
&amp;gt; - nattokinxxxx
# 個人ブログなので不要
&amp;lt; role: Professor of Artificial Intelligence
&amp;lt;
&amp;lt; organizations:
&amp;lt; - name: Stanford University
&amp;lt; url: &amp;quot;&amp;quot;
&amp;lt;
# 簡単な自己紹介
&amp;lt; bio: My research interests include distributed robotics, mobile computing and programmable matter.
---
&amp;gt; bio: Gopherくんかわいい
# 興味
interests:
&amp;lt; - Artificial Intelligence
&amp;lt; - Computational Linguistics
&amp;lt; - Information Retrieval
---
&amp;gt; - Golang
&amp;gt; - K8s
&amp;gt; - Vue.js
&amp;gt; - etc...
# 学歴は削除
&amp;lt; education:
&amp;lt; courses:
&amp;lt; - course: PhD in Artificial Intelligence
&amp;lt; institution: Stanford University
&amp;lt; year: 2012
&amp;lt; - course: MEng in Artificial Intelligence
&amp;lt; institution: Massachusetts Institute of Technology
&amp;lt; year: 2009
&amp;lt; - course: BSc in Artificial Intelligence
&amp;lt; institution: Massachusetts Institute of Technology
&amp;lt; year: 2008
# SNSやGitHub
social:
&amp;lt; link: https://twitter.com/GeorgeCushen
---
&amp;gt; link: https://twitter.com/nattokinxxxx
&amp;lt; link: https://github.com/gcushen
---
&amp;gt; link: https://github.com/nattokin
# Gravatarは使わないので削除
&amp;lt; email: &amp;quot;&amp;quot;
# People widgetは使わないので削除
&amp;lt; user_groups:
&amp;lt; - Researchers
&amp;lt; - Visitors
# 自己紹介（使わないので書いてない /authors/{ユーザー名}/ に表示される）
&amp;lt; Nelson Bighetti is a professor of artificial intelligence at the Stanford AI Lab. His research interests include distributed robotics, mobile computing and programmable matter. He leads the Robotic Neurobiology group, which develops self-reconfiguring robots, systems of self-organizing robots, and mobile sensor networks.
&amp;lt;
&amp;lt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
&amp;lt;
&lt;/code>&lt;/pre>
&lt;h2 id="トップページの編集">トップページの編集&lt;/h2>
&lt;ul>
&lt;li>&lt;code>content/home/&lt;/code> 配下の使わない項目は削除
&lt;ul>
&lt;li>&lt;code>active&lt;/code> に &lt;code>true&lt;/code> をセットすると有効になる&lt;/li>
&lt;li>&lt;code>weight&lt;/code> に入れた数値によって並び順が変わる&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>トップメニューは &lt;code>config/_default/menus.toml&lt;/code> を編集
&lt;ul>
&lt;li>&lt;code>weight&lt;/code> に入れた数値によって並び順が変わる&lt;/li>
&lt;li>不要な項目は削除する&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;code>content/home/posts.md&lt;/code> の編集
&lt;ul>
&lt;li>&lt;code>content.filters.author&lt;/code> は個人ブログで不要なので削除&lt;/li>
&lt;li>&lt;code>design.view&lt;/code> で表示タイプが変更できる（1: リスト 2: コンパクト 3: カード）&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="cssのカスタマイズ">CSSのカスタマイズ&lt;/h2>
&lt;p>&lt;code>assets&lt;/code> に &lt;code>scss&lt;/code> フォルダを作成して &lt;code>custom.scss&lt;/code> を作成。
拡張子は &lt;code>css&lt;/code> ではなく &lt;code>scss&lt;/code> なので注意。&lt;/p>
&lt;p>Scssは煩雑になりがちなCSSを効率的に記述・管理できるメタ言語です。&lt;/p>
&lt;h3 id="例">例&lt;/h3>
&lt;pre>&lt;code class="language-scss">// assets/scss/custom.scss
// プロフィール画像のサイズ調整
.avatar {
width: 150px;
height: 150px;
}
// 記事トップのスペースを開ける
h1 {
margin-top: 2rem;
}
// サブタイトルとメタデータの間の隙間をなくす
p.page-subtitle {
margin-bottom: 0;
}
// メタデータを右寄せして本文との間にスペースを開ける
div.article-metadata {
margin-bottom: 5rem;
text-align: right;
}
// ヘッダー前後の余白が詰まっていたので広げる
h2,
h3,
h4,
h5,
h6 {
margin-top: 2rem;
margin-bottom: 2rem;
}
// 記事内の画像の前後の余白を広げる
.article-style img,
.article-style video {
margin-top: 3rem;
margin-bottom: 3rem;
}
&lt;/code>&lt;/pre>
&lt;h2 id="ハイライトスタイルの変更">ハイライトスタイルの変更&lt;/h2>
&lt;p>
&lt;a href="https://highlightjs.org/static/demo/" target="_blank" rel="noopener">ここ&lt;/a>で色合いを確認して&lt;/p>
&lt;p>
&lt;a href="https://cdnjs.com/libraries/highlight.js/" target="_blank" rel="noopener">ここ&lt;/a>で名前を探す（cssのタブ）&lt;/p>
&lt;pre>&lt;code class="language-diff"># tomorrow-night-bright.css を利用
&amp;lt; # highlight_style = &amp;quot;github&amp;quot; # For supported styles, see https://cdnjs.com/libraries/highlight.js/
&amp;gt; highlight_style = &amp;quot;tomorrow-night-bright&amp;quot; # For supported styles, see https://cdnjs.com/libraries/highlight.js/
&lt;/code>&lt;/pre></description></item><item><title>Hugo(Academic) + Netlifyで無料のブログ構築</title><link>https://blog.nattokinxxxx.net/post/hugo-netlify/</link><pubDate>Wed, 01 Apr 2020 22:00:10 +0900</pubDate><guid>https://blog.nattokinxxxx.net/post/hugo-netlify/</guid><description>&lt;p>HugoとNetlifyでブログ構築したので備忘録。&lt;/p>
&lt;h2 id="なぜhugoとnetlifyなのか">なぜHugoとNetlifyなのか？&lt;/h2>
&lt;ul>
&lt;li>無料でできる（大事）&lt;/li>
&lt;li>ブログの執筆は書き慣れたMarkdownで気軽に行いたい&lt;/li>
&lt;li>いい感じのテンプレートがあった（Academic）&lt;/li>
&lt;li>NetlifyはCIがついていてデフォルトでHugoに対応している&lt;/li>
&lt;li>GitHubのプライベートリポジトリでも無料で使える&lt;/li>
&lt;/ul>
&lt;p>静的サイトジェネレータには他にもGatsbyとかHexoとかJekyllとかありますが、Go製だったのでHugoにしました。
HugoはGoの &lt;code>html/template&lt;/code> と &lt;code>text/template&lt;/code> をベースに作られてるらしいのでカスタムしやすそうだと思ったのも理由の一つです。&lt;/p>
&lt;h2 id="hugoのインストール">Hugoのインストール&lt;/h2>
&lt;p>まずは前準備&lt;/p>
&lt;pre>&lt;code class="language-bash">$ brew install hugo
&lt;/code>&lt;/pre>
&lt;h2 id="テンプレートのインストール">テンプレートのインストール&lt;/h2>
&lt;p>
&lt;a href="https://sourcethemes.com/academic/docs/install/#install-with-git" target="_blank" rel="noopener">こちら&lt;/a>を参考に。&lt;/p>
&lt;pre>&lt;code class="language-bash">$ git clone https://github.com/sourcethemes/academic-kickstart.git My_Website
# サブモジュールの更新
$ cd My_Website
$ git submodule update --init --recursive
&lt;/code>&lt;/pre>
&lt;p>ローカルで確認してみる&lt;/p>
&lt;pre>&lt;code class="language-bash">$ hugo server
| EN
-------------------+-----
Pages | 36
Paginator pages | 0
Non-page files | 1
Static files | 5
Processed images | 11
Aliases | 5
Sitemaps | 1
Cleaned | 0
Built in 468 ms
Watching for changes in /Users/jun/project/My_Website/{assets,content,data,static,themes}
Watching for config changes in /Users/jun/project/My_Website/config.toml, /Users/jun/project/My_Website/config/_default
Environment: &amp;quot;development&amp;quot;
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
&lt;/code>&lt;/pre>
&lt;p>
&lt;a href="http://localhost:1313" target="_blank" rel="noopener">http://localhost:1313&lt;/a> で確認&lt;/p>
&lt;p>&lt;img src="academic_demo.png" alt="デモ画面">&lt;/p>
&lt;h2 id="githubにpush">GitHubにpush&lt;/h2>
&lt;p>リポジトリはプライベートでもパブリックでもいいです。&lt;/p>
&lt;pre>&lt;code class="language-sh">$ rm -rf .git
$ git init
# hubコマンドを利用する場合（パブリックの場合は -p なし）
$ hub create -p
$ git remote -v
origin git@github.com:xxx/My_Website.git (fetch)
origin git@github.com:xxx/My_Website.git (push)
# 手動でリポジトリを作成する場合
$ git remote add origin git@github.com:nattokin/My_Website.git
$ git remote -v
origin git@github.com:xxx/My_Website.git (fetch)
origin git@github.com:xxx/My_Website.git (push)
$ git add .
$ git commit -m &amp;quot;first commit&amp;quot;
$ git push origin master
&lt;/code>&lt;/pre>
&lt;h2 id="netlify登録デプロイ">Netlify登録&amp;amp;デプロイ&lt;/h2>
&lt;h3 id="ログイン">ログイン&lt;/h3>
&lt;p>
&lt;a href="https://app.netlify.com/" target="_blank" rel="noopener">こちら&lt;/a>からGitHubアカウントでログイン&lt;/p>
&lt;h3 id="リポジトリの選択">リポジトリの選択&lt;/h3>
&lt;p>&lt;code>New Site from Git&lt;/code> から対象のGitHub&amp;gt;リポジトリを選択します。&lt;/p>
&lt;p>&lt;img src="new_site_from_git.png" alt="Netlifyリポジトリ登録画面">&lt;/p>
&lt;h3 id="デプロイ">デプロイ&lt;/h3>
&lt;p>デフォルトのままでok。
設定ファイル &lt;code>netlify.toml&lt;/code> の内容が優先されるので無視されます。&lt;/p>
&lt;ul>
&lt;li>&lt;code>Branch to deploy&lt;/code> : &lt;code>master&lt;/code>&lt;/li>
&lt;li>&lt;code>Build command&lt;/code> : &lt;code>hugo&lt;/code>&lt;/li>
&lt;li>&lt;code>Publish directory&lt;/code> : &lt;code>public&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>&lt;code>Deploy site&lt;/code> を押す。&lt;/p>
&lt;p>&lt;img src="deploy_site.png" alt="Netlifyデプロイ画面">&lt;/p>
&lt;p>デプロイ完了。リンク先で確認。&lt;/p>
&lt;p>&lt;img src="deploy_finished.png" alt="デプロイ完了画面">&lt;/p>
&lt;h2 id="academicの設定">Academicの設定&lt;/h2>
&lt;p>基本設定の変更はこんな感じ&lt;/p>
&lt;pre>&lt;code class="language-toml"># config/_default/config.toml
# 最下部のコピーライトに表示されるやつ
- copyright = &amp;quot;&amp;quot;
+ copyright = &amp;quot;&amp;amp;copy; 2020 nattokinxxxx All Rights Reserved.&amp;quot;
# 言語設定
- defaultContentLanguage = &amp;quot;en&amp;quot;
- hasCJKLanguage = false # Set `true` for Chinese/Japanese/Korean languages.
+ defaultContentLanguage = &amp;quot;ja&amp;quot;
+ hasCJKLanguage = true # Set `true` for Chinese/Japanese/Korean languages.
# 記事のフィルタなどに使用するようだが自分しか投稿しないので不要
[taxonomies]
tag = &amp;quot;tags&amp;quot;
category = &amp;quot;categories&amp;quot;
publication_type = &amp;quot;publication_types&amp;quot;
- author = &amp;quot;authors&amp;quot;
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-toml"># config/_default/languages.toml
- [en]
- languageCode = &amp;quot;en-us&amp;quot;
+　[ja]
+ languageCode = &amp;quot;ja&amp;quot;
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-toml"># config/_default/params.toml
# サイトの文字サイズ
- font_size = &amp;quot;L&amp;quot;
+ font_size = &amp;quot;M&amp;quot;
# ヘッダーのdescription
- description = &amp;quot;&amp;quot;
+ description = &amp;quot;エンジニアのブログ&amp;quot;
&lt;/code>&lt;/pre>
&lt;h2 id="まとめ">まとめ&lt;/h2>
&lt;ul>
&lt;li>Netlifyへのデプロイ周りはすごく簡単&lt;/li>
&lt;li>テンプレートのカスタマイズについては
&lt;a href="../customize-academic/">こちら&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>