Movable Typeのブログに投稿した内容を別ページで使用する機会があったので、RSSの配信を試してみました。
バージョンは6.0.8を使用しています。
実装方法
管理画面の該当ブログを開いて、デザイン > テンプレート > インデックステンプレート の「インデックステンプレートの作成」をクリックします。

テンプレート名を「rss」、出力ファイル名を「rss.xml」にして、以下の内容を入力します。
<$mt:HTTPContentType type="application/atom+xml"$><?xml version="1.0" encoding="<$mt:PublishCharset$>"?>
<rss version="2.0">
<channel>
<title><$mt:BlogName remove_html="1" encode_xml="1"$></title>
<link><$mt:BlogURL encode_xml="1"$></link>
<description><$mt:BlogDescription remove_html="1" encode_xml="1"$></description>
<MTEntries lastn="15">
<item>
<title><$mt:EntryTitle remove_html="1" encode_xml="1"$></title>
<link><$mt:EntryPermalink encode_xml="1"$></link>
<description><$mt:EntryBody encode_xml="1"$></description>
<pubDate><$mt:EntryDate format_name="rfc822"$></pubDate>
<mt:EntryCategories>
<category><$mt:CategoryLabel encode_xml="1"$></category>
</mt:EntryCategories>
</item>
</MTEntries>
</channel>
</rss>
入力完了後、保存と再構築を行えば完了です。
実際にRSSファイルを確認すると、以下のように表示されました。
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>BLOG</title>
<link>https://XXXXX/blog/</link>
<description>BLOGの説明文です。設定 > 全般 > 説明 のテキストが入ります。</description>
<item>
<title>記事B</title>
<link>https://XXXXX/blog/2018/08/b.html</link>
<description><![CDATA[<p>記事Bの内容テキスト</p>]]></description>
<pubDate>Sat, 25 Aug 2018 20:41:37 +0900</pubDate>
<category>catA</category>
<category>catB</category>
</item>
<item>
<title>記事A</title>
<link>https://XXXXX/blog/2018/08/a.html</link>
<description><![CDATA[<p>記事Aの内容です。</p>]]></description>
<pubDate>Sat, 25 Aug 2018 20:35:05 +0900</pubDate>
<category>catA</category>
</item>
</channel>
</rss>
今回は最低限の項目しか入れていないので、使用する項目などに合わせてテンプレートに追加・修正を行ってください。
例えば、記事本文のタグが不要な場合、11行目を以下のように変更します。
<description><$mt:EntryBody remove_html="1" encode_xml="1"$></description>
remove_html=”1″を追加しています。
再構築すると以下のように変更されました。
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>BLOG</title>
<link>https://XXXXX/blog/</link>
<description>BLOGの説明文です。設定 > 全般 > 説明 のテキストが入ります。</description>
<item>
<title>記事B</title>
<link>https://XXXXX/blog/2018/08/b.html</link>
<description>記事Bの内容です。</description>
<pubDate>Sat, 25 Aug 2018 20:41:37 +0900</pubDate>
<category>catA</category>
<category>catB</category>
</item>
<item>
<title>記事A</title>
<link>https://XXXXX/blog/2018/08/a.html</link>
<description>記事Aの内容です。</description>
<pubDate>Sat, 25 Aug 2018 20:35:05 +0900</pubDate>
<category>catA</category>
</item>
</channel>
</rss>
最後にhead内にlinkタグを追加しておきます。
デザイン > テンプレート > テンプレートモジュール > HTMLヘッダー 内に以下を追記します。
<link rel="alternate" type="application/rss+xml" title="RSS" href="<$mt:BlogURL$>rss.xml" />
再構築すると、linkタグが追加されました。
<link rel="alternate" type="application/rss+xml" title="RSS" href="https://XXXXX/blog/rss.xml" />
【参考サイト】
- Movable Type 4.2以降でRSS 2.0のフィードを配信する – The blog of H.Fujimoto
- MTHTTPContentType – テンプレートタグリファレンス | CMSプラットフォーム Movable Type ドキュメントサイト
- RSS 2.0 のフォーマット|RSS|Web関連特集|PHP & JavaScript Room
コメントが承認されるまで時間がかかります。