ホームページの重要な情報には<h1>や<h2>などhがつくタグがある。<h1>や<h2>はページ内のタイトルや見出しのようなもので、ページを表示する際にはとても重要なタグである。サイト内のすべてのページで<h1>や<h2>を適切なタグにする必要がある。そのためテンプレートでは「if文」を使って条件分岐している。
MTOSではバージョンによってテンプレートの名称が変更されているが、最新のMTOS4.23ではヘッダー用のテンプレートは2つあるためわかりにくい。
HTMLヘッダーとバナーヘッダーの2つがあるが、ここで改造するのはバナーヘッダーのほうである。
バナーヘッダーは標準では
<mt:If name="main_index">
<h1 id="header-name"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogName encode_html="1"$></a></h1>
<h2 id="header-description"><$mt:BlogDescription$></h2>
<mt:Else>
<div id="header-name"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogName encode_html="1"$></a></div>
<div id="header-description"><$mt:BlogDescription$></div>
</mt:If>
となっている。(if文の中身のみ)
これは、メインインデックスページ(index.html)のみの<h1>や<h2>を指定している。エントリーページやカテゴリページの<h1>や<h2>は、それぞれのテンプレートに記述をまかす形式になっている。
しかし、このままでは<h1>や<h2>の表示位置がindex.htmlと他のページが違うことになってしまう。そこで、同じ位置に<h1>や<h2>を表示し、それぞれのページで同じ内容にならないようにバナーヘッダーテンプレートをカスタマイズした。
バナーヘッダのテンプレートの記述例は以下のとおり。 (この内容はカスタマイズ版データと同じ)
<div id="header">
<div id="header-inner">
<div id="header-content">
<mt:Ignore><!-- Use h1 and h2 html tags on the main index of the blog as the title, use divs on all other pages where there are page titles. --></mt:Ignore>
<mt:If name="entry_template">
<h1 id="header-name"><$MTEntryTitle$>は<$mt:BlogName encode_html="1"$></h1>
<h2 id="header-description"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogDescription$></a></h2>
<p><$MTEntryTitle$>は<$mt:BlogName encode_html="1"$></p>
<mt:Else>
<mt:If name="Category_archive">
<h1 id="header-name"><$MTCategoryLabel$>は<$mt:BlogName encode_html="1"$></h1>
<h2 id="header-description"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogDescription$></a></h2>
<p><$MTCategoryLabel$>は<$mt:BlogName encode_html="1"$></p>
<mt:Else>
<mt:If name="datebased_archive">
<h1 id="header-name"><$mt:ArchiveTitle$>:<$mt:BlogName encode_html="1"$></h1>
<h2 id="header-description"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogDescription$></a></h2>
<p><$mt:ArchiveTitle$>:<$mt:BlogName encode_html="1"$></p>
<mt:Else>
<mt:If name="search_results">
<h1 id="header-name"><$MTSearchString$>は<$mt:BlogName encode_html="1"$></h1>
<h2 id="header-description"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogDescription$></a></h2>
<p><$MTSearchString$>は<$mt:BlogName encode_html="1"$></p>
<mt:Else>
<h1 id="header-name"><$mt:BlogName encode_html="1"$></h1>
<h2 id="header-description"><a href="<$mt:BlogURL$>" accesskey="1"><$mt:BlogDescription$></a></h2>
<p><$mt:BlogName encode_html="1"$>は<$mt:BlogDescription$></p>
</mt:If>
</mt:If>
</mt:If>
</mt:If>
</div>
</div>
</div>
フェイスブックの「いいね」はいいですね。
![]()
|
遠田幹雄の業務経歴書の請求はこちら
のメールフォームからどうぞ
それぞれSSLのフォームになっています。