Liquid Snippets by ALSEL
📘 公式リファレンス📦 リファレンス/オブジェクト初級

article オブジェクト

ブログ記事の情報にアクセスするオブジェクト。タイトル、著者、公開日時、メタフィールド、アイキャッチ画像など記事に紐づく全データを参照できる。

用途
ブログページ(article.liquid テンプレート)で記事のタイトル・本文・著者・投稿日を表示したり、ブログ一覧ページで記事の要約情報を描画するとき。
設置場所
Liquid テンプレート内で `{{ article.title }}`、`{{ article.author }}`、`{{ article.published_at | date: '%Y年%m月%d日' }}` のように各プロパティを参照する。記事ループ内では `{% for article in blog.articles %} {{ article.title }} {% endfor %}` で複数記事に順次アクセスする。
注意点
`created_at`、`published_at`、`updated_at` はタイムスタンプ文字列で返されるため、表示前に `date` フィルターで整形する必要がある(例: `{{ article.published_at | date: '%B %d, %Y' }}`)。コメント機能が無効の場合 `article.comments` は空配列を返す。`template_suffix` はカスタムテンプレートが割り当てられていないと `nil` を返すため、値の有無をチェックしてから参照する。
タグ:articleblogtimestampmetafield

仕様

379 行 / json
{
  "access": {
    "global": false,
    "parents": [
      {
        "object": "articles",
        "property": ""
      },
      {
        "object": "blog",
        "property": "articles"
      }
    ],
    "template": [
      "article"
    ]
  },
  "deprecated": false,
  "deprecation_reason": "",
  "description": "",
  "properties": [
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "image",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The featured image for the article.",
      "name": "image"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The full name of the author of the article.",
      "name": "author"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "> Tip:\n> To learn about how to create metafields, refer to [Create and manage metafields](/apps/metafields/manage) or visit\n> the [Shopify Help Center](https://help.shopify.com/manual/metafields).",
      "examples": [],
      "return_type": [
        {
          "type": "untyped",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [metafields](/docs/api/liquid/objects/metafield) applied to the article.",
      "name": "metafields"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [handle](/docs/api/liquid/basics#handles) of the article.",
      "name": "handle"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The ID of the article.",
      "name": "id"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The title of the article.",
      "name": "title"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The relative URL of the article.",
      "name": "url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "The name doesn't include the `article.` prefix, or the file extension (`.json` or `.liquid`).\n\n If a custom template isn't assigned to the article, then `nil` is returned.",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The name of the [custom template](/themes/architecture/templates#alternate-templates) assigned to the article.",
      "name": "template_suffix"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "> Tip:\n> Use the [`date` filter](/docs/api/liquid/filters/date) to format the timestamp.",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "A timestamp for when the article was created.",
      "name": "created_at"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "> Tip:\n> Use the [`date` filter](/docs/api/liquid/filters/date) to format the timestamp.",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "A timestamp for when the article was published.",
      "name": "published_at"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "> Tip:\n> Use the [`date` filter](/docs/api/liquid/filters/date) to format the timestamp.",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "A timestamp for when the article was updated.",
      "name": "updated_at"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "boolean",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "Returns `true` if the blog that the article belongs to is set to [moderate comments](https://help.shopify.com/manual/online-store/blogs/managing-comments).\nReturns `false` if not.",
      "name": "moderated?"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "Returns an empty array if comments are disabled.\n\n> Tip:\n> Use the [paginate](/docs/api/liquid/tags/paginate) tag to choose how many comments to show at once, up to a limit of 50.",
      "examples": [],
      "return_type": [
        {
          "type": "array",
          "name": "",
          "description": "",
          "array_value": "comment"
        }
      ],
      "summary": "The published comments for the article.",
      "name": "comments"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "number",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The number of published comments for the article.",
      "name": "comments_count"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "boolean",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "Returns `true` if comments are enabled. Returns `false` if not.",
      "name": "comments_enabled?"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The relative URL where POST requests are sent when creating new comments.",
      "name": "comment_post_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The content of the article.",
      "name": "content"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The excerpt of the article.",
      "name": "excerpt"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "Returns the article [excerpt](/docs/api/liquid/objects/article#article-excerpt) if it exists. Returns the article\n[content](/docs/api/liquid/objects/article#article-content) if no excerpt exists.",
      "name": "excerpt_or_content"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [
        {
          "name": "Show the total tag count",
          "description": "When looping through `article.tags`, you can print how many times a tag is used with `tag.total_count`. This number shows visitors how many blog posts have been tagged with a particular tag.\n",
          "syntax": "",
          "path": "/blogs/potion-notions/how-to-tell-if-you-have-run-out-of-invisibility-potion",
          "raw_liquid": "{% for tag in article.tags -%}\n  {{ tag }} ({{ tag.total_count }})\n{%- endfor %}",
          "parameter": false,
          "display_type": "text",
          "show_data_tab": true
        }
      ],
      "return_type": [
        {
          "type": "array",
          "name": "",
          "description": "",
          "array_value": "string"
        }
      ],
      "summary": "The tags applied to the article.",
      "name": "tags"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "user",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The user associated with the author of the article.",
      "name": "user"
    }
  ],
  "summary": "An article, or [blog post](https://help.shopify.com/manual/online-store/blogs/writing-blogs), in a blog.",
  "name": "article",
  "examples": [],
  "json_data": {
    "path": "/blogs/potion-notions/how-to-tell-if-you-have-run-out-of-invisibility-potion",
    "handle": "article",
    "data_from_file": ""
  },
  "return_type": []
}

出典・ライセンス

License:
MIT

このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。

関連項目

📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_header オブジェクト

Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。

📁 theme-liquid-docs·MIT·20
📘 公式リファレンス📦 リファレンス/オブジェクト中級

metaobjects オブジェクト

ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。

📁 theme-liquid-docs·MIT·20
📘 公式リファレンス📦 リファレンス/オブジェクト初級

additional_checkout_buttons オブジェクト

PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

canonical_url オブジェクト

現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_index オブジェクト

ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_additional_checkout_buttons オブジェクト

PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。

📁 theme-liquid-docs·MIT·27