テンプレートごとに違う内容を出力するhead要素を作成する
くれま先輩:そこまでできたら,
ほげ山くん:さっき準備していなかった
くれま先輩:そう,
<meta http-equiv="Content-Type" content="text/html; charset=<mt:PublishCharset />" />
<!-- ▼title要素ここから▼ -->
<mt:If name="sitemap"><title>サイトマップ|<mt:BlogName /></title></mt:If>
<mt:If name="main_index"><title><mt:BlogName /></title></mt:If>
<mt:IfArchiveType archive_type="Page"><title><mt:PageTitle />|<mt:BlogName /></title></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Individual"><title><mt:EntryTitle />|<mt:EntryCategory />|<mt:BlogName /></title></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Category"><title><mt:CategoryLabel />|<mt:BlogName /></title></mt:IfArchiveType>
<mt:If name="search_results"><title>タグ「<mt:SearchString />」がついているエントリー | <mt:BlogName /></title></mt:If>
<!-- ▲title要素ここまで▲ -->
<!-- ▼meta要素 descriptionここから▼ -->
<mt:If name="sitemap"><meta name="description" content="<mt:BlogName />のサイトマップです。<mt:BlogDescription />" /></mt:If>
<mt:If name="main_index"><meta name="description" content="<mt:BlogDescription />" /></mt:If>
<mt:IfArchiveType archive_type="Page"><meta name="description" content="<mt:PageExcerpt />" /></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Individual"><meta name="description" content="<mt:EntryExcerpt />" /></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Category"><meta name="description" content="<mt:CategoryDescription />" /></mt:IfArchiveType>
<mt:If name="search_results"><meta name="description" content="<mt:BlogName />の検索結果です。<mt:BlogDescription />" /></mt:If>
<!-- ▲meta要素 descriptionここまで▲ -->
<!-- ▼meta要素 keywordsここから▼ -->
<mt:If name="sitemap"><meta name="keywords" content="<mt:Include module="基本キーワード" />" /></mt:If>
<mt:If name="main_index"><meta name="keywords" content="<mt:Include module="基本キーワード" />" /></mt:If>
<mt:IfArchiveType archive_type="Page"><meta name="keywords" content="<mt:PageKeywords /><mt:Include module="基本キーワード" />" /></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Individual"><meta name="keywords" content="<mt:EntryKeywords /><mt:Include module="基本キーワード" />" /></mt:IfArchiveType>
<mt:IfArchiveType archive_type="Category"><meta name="keywords" content="<mt:CategoryKeywords /><mt:Include module="基本キーワード" />" /></mt:IfArchiveType>
<mt:If name="search_results"><meta name="keywords" content="<mt:Include module="基本キーワード" />" /></mt:If>
<!-- ▲meta要素 keywordsここまで▲ -->
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="<mt:Link template="feed_recent">" />
<link rel="stylesheet" type="text/css" href="<mt:BlogUrl />styles.css " media="screen,print" title="default" />
ほげ山くん:mt:Ifを使って,
くれま先輩:うん。アーカイブテンプレートの
ほげ山くん:archive_
くれま先輩:そうそう。同じように,
ほげ山くん:なるほど,
くれま先輩:そうなのよ。だから,
<mt:Include module="head要素" />の直前の行に追加する変数名
インデックステンプレート | |
---|---|
サイトマップ | <mt:SetVar name="sitemap" value="1" /> |
メインページ | <mt:SetVar name="main_index" value="1" /> |
システムテンプレート | |
検索結果 | <mt:SetVar name="search_results" value="1" /> |
ほげ山くん:これを追加すると,
くれま先輩:なになに?
ほげ山くん:<mt:Include module="基本キーワード" />と書いてある部分って,
くれま先輩:あたり!
ほげ山くん:この中に出てくるMTタグをリファレンスで調べてたんですけど,
くれま先輩:一見本当にありそうな名前だけど,
ほげ山くん:Web業界の友人に指摘されたんですけど,
くれま先輩:うーん。今は説明をわかりやすくするためにこういう書き方をしているけど,
ほげ山くん:ぜひお願いします!!
くれま先輩:了解!
次回予告
- 基本キーワードのテンプレートモジュールを作ろう。
- カテゴリー用キーワードのカスタムフィールドを作ろう。
- グローバルナビゲーションのテンプレートモジュールを作ろう。