RSS2.0のフィード配信方法(MT4.25)
テンプレートを作成します。
インデックステンプレートを新規作成。
テンプレート名は「RSS2.0」、出力ファイル名を「index.xml」、テンプレートの種類を「最新記事のフィード」にし、以下のソース内容を貼り付ける。
<$MTHTTPContentType type="application/rss+xml"$>
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rss version="2.0">
<channel>
<title><$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description>
<$MTBlogDescription remove_html="1" encode_xml="1"$>
</description>
<language><$MTBlogLanguage ietf="1"$></language>
<copyright>Copyright <$MTDate format="%Y"$></copyright>
<lastBuildDate>
<MTEntries lastn="1"><$MTEntryDate format_name="rfc822"$></MTEntries>
</lastBuildDate>
<generator>http://www.sixapart.com/movabletype/</generator>
<docs>http://www.rssboard.org/rss-specification</docs>
<MTEntries lastn="15">
<item>
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
<description><$MTEntryBody encode_xml="1"$></description>
<link><$MTEntryPermalink encode_xml="1"$></link>
<guid><$MTEntryPermalink encode_xml="1"$></guid>
<MTEntryCategories>
<category domain="http://www.sixapart.com/ns/types#category">
<$MTCategoryLabel remove_html="1" encode_xml="1"$>
</category>
</MTEntryCategories>
<MTEntryIfTagged><MTEntryTags>
<category domain="http://www.sixapart.com/ns/types#tag">
<$MTTagName remove_html="1" encode_xml="1"$>
</category>
</MTEntryTags></MTEntryIfTagged>
<pubDate><$MTEntryDate format_name="rfc822"$></pubDate>
</item>
</MTEntries>
</channel>
</rss>
テンプレートの「HTMLヘッダー」に以下の赤字部分を書き加える。
これは、
WebページのHTMLからフィードの情報を検知して、アドレスバーにフィードのアイコンを表示する機能
だそうです。
<link rel="alternate" type="application/atom+xml" title="Recent Entries(Atom)" href="<$mt:Link template="feed_recent"$>" />
<link rel="alternate" type="application/rss+xml" title="Recent Entries(RSS 2.0)" href="<$mt:BlogURL$>index.xml" />
サイドバー等にRSS 2.0へのリンクを出力するようにして、ブログの読者がRSS 2.0のフィードをRSSリーダーに登録しやすくなるようにするため、ウェジットの「購読」に以下の赤字部分を書き加える。
<li><img src="<$mt:StaticWebPath$>images/status_icons/feed.gif" alt="購読する(Atom)" width="9" height="9" /> <a href="<$mt:Link template="feed_recent"$>">このブログを購読(Atom)</a></li>
<li><img src="<$mt:StaticWebPath$>images/status_icons/feed.gif" alt="購読する(RSS 2.0)" width="9" height="9" /> <a href="<$mt:BlogURL$>index.xml">このブログを購読(RSS 2.0)</a></li>
以上です。
ちなみに青色文字部を私は適当に変更しています。
コメントする