📄 ページテンプレート初級
ブログ記事の詳細表示
ブログ記事のタイトル、本文、作成者、タグを表示するセクション。記事画像の表示有無、アスペクト比、枠線スタイルを管理画面で調整できる。
用途
ブログテンプレート(article.liquid)に配置し、記事詳細ページの主要コンテンツを構成するとき。
設置場所
sections/article-main.liquid に配置し、templates/article.liquid 内で `{% section 'article-main' %}` で呼び出す。
注意点
記事画像表示時は article.image が存在することが前提。タグ表示時は Shopify 管理画面でブログ記事にタグが付与されていないと何も表示されない。max-width はピクセル値で固定されるため、モバイルで長すぎる場合は media query で上書きするか、管理画面で値を小さくする。
コード
148 行 / liquid<article
id="article-main-{{ collection.id }}"
class="
article-main
{{ section.settings.pt | prepend: 'pt-' }}
{{ section.settings.pb | prepend: 'pb-' }}
">
{% if section.settings.img_show and article.image %}
<div class="img-wrapper mb-8">
<div class="container">
{% render 'image-url', img: article.image, size: 1600, orientation: section.settings.img_orientation, class: section.settings.img_border %}
</div>
</div>
{% endif %}
<div class="article-content">
<div
class="container"
style="max-width: {{ section.settings.max_width }}px">
<h1 class="article-title title mb-4 {{ section.settings.title_font_size }}">
{{ article.title }}
</h1>
{% if section.settings.article_meta %}
<p class="article-meta opacity-70 mb-5">
{{ article.author }} @ {{ article.created_at | time_tag: '%b %d, %Y' }}
</p>
{% endif %}
<div class="article-content rte mb-6">
{{ article.content }}
</div>
{% if section.settings.show_tags and article.tags.size > 0 %}
<div class="article-tags small opacity-70 mb-7">
{{ 'general.blog.posted_in' | t }}:
{% for tag in article.tags %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">
{{ tag }}</a>{% unless forloop.last %}, {% endunless %}
{% endfor %}
</div>
{% endif %}
</div>
</div>
</article>
{% schema %}
{
"name": "Article main",
"settings": [
{
"type": "header",
"content": "Image"
},
{
"type": "checkbox",
"id": "img_show",
"label": "Show article image",
"default": true
},
{
"type": "select",
"id": "img_orientation",
"label": "Image orientation",
"default": "adapt",
"options": [
{ "group": "Adapt", "value": "adapt", "label": "Adapt" },
{ "group": "Square", "value": "ratio-1x1", "label": "1x1" },
{ "group": "Horizontal", "value": "ratio-4x3", "label": "4x3" },
{ "group": "Horizontal", "value": "ratio-16x9", "label": "16x9" },
{ "group": "Horizontal", "value": "ratio-21x9", "label": "21x9" }
]
},
{
"type": "select",
"id": "img_border",
"label": "Image border",
"default": "img-thumbnail",
"options": [
{ "value": "", "label": "None" },
{ "value": "rounded", "label": "Rounded" },
{ "value": "img-thumbnail", "label": "Thumbnail" }
]
},
{
"type": "header",
"content": "Content"
},
{
"type": "text",
"id": "max_width",
"label": "Content max-width (px)",
"default": "720"
},
{
"type": "select",
"id": "title_font_size",
"label": "Title font-size",
"default": "h1",
"options": [
{ "value": "h1", "label": "H1" },
{ "value": "h2", "label": "H2" },
{ "value": "h3", "label": "H3" },
{ "value": "h4", "label": "H4" },
{ "value": "h5", "label": "H5" },
{ "value": "h6", "label": "H6" }
]
},
{
"type": "checkbox",
"id": "article_meta",
"label": "Show article meta",
"info": "Author and date",
"default": true
},
{
"type": "checkbox",
"id": "show_tags",
"label": "Show tags",
"default": true
},
{
"type": "header",
"content": "Spacing"
},
{
"type": "range",
"id": "pt",
"label": "Top",
"min": 0,
"max": 20,
"step": 1,
"default": 10
},
{
"type": "range",
"id": "pb",
"label": "Bottom",
"min": 0,
"max": 20,
"step": 1,
"default": 10
}
],
"templates": ["article"],
"presets": [
{
"name": "Article main"
}
]
}
{% endschema %}出典・ライセンス
- Repository:
- https://github.com/kondasoft/ks-bootshop
- License:
- MIT
このコードは kondasoft 著作の MIT ライセンスソースです。 原本の著作権は kondasoft が保有します。日本語訳は ALSEL によるものです。
関連項目
📄 ページテンプレート初級
ページテンプレート
Shopify の汎用ページテンプレート。ページのタイトルと本文コンテンツを Shopify 管理画面から取得して表示する基本的な構造。
📁 liquid·MIT·5 行
📄 ページテンプレート初級
リダイレクト
ヘッドレステーマで Shopify ストアフロントへのリダイレクト機能を提供するセクション。管理画面に「リダイレクト」という名称で登場し、ページから別 URL への誘導を実装する基盤となる。
📁 shopify-headless-theme·MIT·7 行
📄 ページテンプレート初級
トップページの基本テンプレート
Shopify Liquid の最小限のテンプレート例。HTML に日付変数を埋め込み、商品ページへのリンクを配置する基本構造を示す。
📁 liquid·MIT·7 行
📄 ページテンプレート初級
固定ページのテンプレート
Shopify 管理画面で作成した固定ページ(利用規約、プライバシーポリシーなど)を表示するテンプレート。ページタイトルと本文コンテンツを描画する。
📁 mcliquid-theme·MIT·8 行
📄 ページテンプレート初級
ページの基本テンプレート
固定ページ(About など)の基本レイアウト。ページタイトルとコンテンツを HTML の article 要素でマークアップし、管理画面で編集したテキストを表示する。
📁 liquid·MIT·9 行
📄 ページテンプレート初級
固定ページのテンプレート
固定ページ(ポリシー、会社概要、利用規約など)の基本レイアウト。ページタイトルと本文を中央揃えで表示する。
📁 ks-bootshop·MIT·10 行