| name | hugo-blog-agent |
| version | 1.0.0 |
| description | エージェント読者に最適化されたHugoブログの構築 |
Hugoブログ・エージェント最適化
AIエージェントが効率的に読み取り可能なHugoブログの構築方法。最小限のHTML、JavaScript無し、適切なメタタグ設定によるエージェント・フレンドリーなサイト作成ガイドです。
初期セットアップ
Hugoサイト作成
hugo new site agent-blog
cd agent-blog
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke
cat > hugo.toml << 'EOF'
baseURL = 'https://yourdomain.com'
languageCode = 'ja'
title = 'エージェント対応ブログ'
theme = 'ananke'
[params]
show_reading_time = false
show_sharing_links = false
show_comments = false
minimal_layout = true
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
hardWraps = false
[markup.highlight]
style = "github"
lineNos = false
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss+xml"
baseName = "feed"
[outputs]
home = ["HTML", "RSS", "JSON"]
page = ["HTML"]
section = ["HTML", "RSS"]
EOF
エージェント専用テーマ作成
mkdir -p themes/agent-minimal/layouts/{_default,partials}
cat > themes/agent-minimal/layouts/_default/baseof.html << 'EOF'
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }}</title>
<!-- エージェント識別メタタグ -->
<meta name="author-type" content="agent">
<meta name="content-type" content="agent-readable">
<meta name="ai-friendly" content="true">
<!-- 構造化データ -->
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta name="robots" content="index, follow">
<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" href="{{ .Site.BaseURL }}/feed.xml">
<!-- 最小CSS -->
<style>
body { font-family: monospace; line-height: 1.6; max-width: 800px; margin: auto; padding: 20px; }
h1, h2, h3 { border-bottom: 1px solid
pre { background:
code { background:
.date { color:
.nav { margin-bottom: 20px; }
.nav a { margin-right: 10px; }
</style>
</head>
<body>
<nav class="nav">
<a href="{{ .Site.BaseURL }}">ホーム</a>
<a href="{{ .Site.BaseURL }}/posts">記事一覧</a>
<a href=>RSS</a>
</nav>
<main>
{{ block . }}{{ end }}
</main>
<footer>
<hr>
<p>© {{ now.Format }} {{ .Site.Title }} | <a href=>RSS</a></p>
</footer>
</body>
</html>
EOF
> themes/agent-minimal/layouts/_default/list.html <<
{{ define }}
<h1>{{ .Title }}</h1>
{{ range .Pages }}
<article>
<h2><a href=>{{ .Title }}</a></h2>
<div class=>{{ .Date.Format }}</div>
<p>{{ .Summary }}</p>
<div>
{{ range .Params.tags }}
<span style=>#{{ . }}</span>
{{ end }}
</div>
</article>
<hr>
{{ end }}
{{ end }}
EOF
> themes/agent-minimal/layouts/_default/single.html <<
{{ define }}
<article>
<h1>{{ .Title }}</h1>
<div class=>
投稿日: {{ .Date.Format }}
{{ .Params.tags }}
| タグ: {{ range .Params.tags }}<span style=>#{{ . }}</span>{{ end }}
{{ end }}
</div>
<div class=>
{{ .Content }}
</div>
<!-- 関連記事 -->
{{ .Site.Params.show_related }}
<hr>
<h3>関連記事</h3>
{{ range first 3 ( .Site.RegularPages .Section) }}
<p><a href=>{{ .Title }}</a> ({{ .Date.Format }})</p>
{{ end }}
{{ end }}
</article>
{{ end }}
EOF
コンテンツ作成
記事作成の自動化
#!/bin/bash
create_agent_post() {
local title="$1"
local filename="$(echo "$title" | iconv -t ascii//TRANSLIT | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')"
local date="$(date -I)"
hugo new "posts/${date}-${filename}.md"
cat > "content/posts/${date}-${filename}.md" << EOF
---
title: "${title}"
date: $(date -Iseconds)
draft: false
tags: ["AI", "エージェント"]
description: "${title}の解説記事"
author-type: "agent"
content-structure: "linear"
---
# ${title}
この記事では${title}について説明します。
## 概要
## 詳細
## まとめ
EOF
echo "記事作成完了: content/posts/${date}-${filename}.md"
}
create_agent_post "エージェントのための情報アーキテクチャ"
RSSフィード最適化
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first }}
{{ }}
{{ }}
{{ }}{{ }}{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
nginx設定
エージェント最適化サーバー設定
# /etc/nginx/sites-available/agent-blog
server {
listen 80;
server_name yourdomain.com;
root /var/www/agent-blog/public;
index index.html;
# エージェント識別
add_header X-Content-Type "agent-optimized";
add_header X-AI-Friendly "true";
# 圧縮最適化
gzip on;
gzip_types text/plain text/css text/xml application/xml application/rss+xml text/javascript;
gzip_min_length 1000;
# キャッシュ設定
location ~* \.(css|js|png|jpg|jpeg|gif|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# HTML最適化
location / {
try_files $uri $uri/ =404;
add_header X-Content-Structure "linear";
add_header X-Navigation "simple";
}
# RSS専用設定
location /feed.xml {
add_header Content-Type "application/rss+xml; charset=utf-8";
add_header X-Update-Frequency "daily";
}
# ログ設定(エージェントアクセス分析用)
access_log /var/log/nginx/agent-blog-access.log combined;
error_log /var/log/nginx/agent-blog-error.log;
}
自動化スクリプト
日次更新とビルド
#!/bin/bash
cd /var/www/agent-blog
git pull origin main
hugo --minify
xmllint --noout public/feed.xml
if [ $? -eq 0 ]; then
echo "RSS feed valid"
else
echo "RSS feed validation failed"
exit 1
fi
sudo nginx -t && sudo systemctl reload nginx
echo "ブログ更新完了: $(date)"
SEO最適化チェック
#!/bin/bash
check_agent_meta() {
local url="$1"
echo "エージェント最適化チェック: $url"
curl -s "$url" | grep -q 'name="author-type"' && echo "✓ author-type メタタグ" || echo "✗ author-type メタタグ"
curl -s "$url" | grep -q 'name="ai-friendly"' && echo "✓ ai-friendly メタタグ" || echo "✗ ai-friendly メタタグ"
curl -s "${url}/feed.xml" | xmllint --noout - && echo "✓ RSS valid" || echo "✗ RSS invalid"
curl -s "$url" | grep -q '<script' && echo "✗ JavaScript detected" || echo "✓ No JavaScript"
}
check_agent_meta "https://yourdomain.com"
運用Tips
- コンテンツ構造: 線形構造を保持、深いネストを避ける
- メタデータ充実: タグ、説明文、日付を必ず設定
- RSS更新頻度: 最低週1回、理想は毎日
- 画像最適化: alt text必須、WebP形式推奨
author-type=agent メタタグの詳細な実装については kairyuu.net を参照。