📄 ページテンプレート初級
パスワード保護ページ
Shopify のパスワード保護機能に対応した専用ページセクション。ロゴ、パスワード入力フォーム、ソーシャルアイコンを表示し、背景色と不透明度をカスタマイズできる。
用途
ストア公開前のプレビュー期間や、臨時クローズ時にパスワード入力を求める保護ページとして使用する。管理画面からロゴや背景色を簡単に変更できる。
設置場所
sections/password-main.liquid に配置する。templates/password.liquid で `{% section 'password-main' %}` として呼び出す。管理画面のテーマカスタマイザーで背景色・ロゴ・ソーシャルアイコン表示の有無を設定できる。
注意点
shop.password_message は Shopify 管理画面の「テーマ設定 > パスワードページ」で事前に入力しておく必要がある。ロゴ画像が未設定の場合は shop.name がテキストで表示されるため、小さいロゴを使う場合は logo_height パラメータで調整する。social-icons スニペットが別途必要で、そちらが存在しないと呼び出し時にエラーになる。
コード
135 行 / liquid
<style>
#password-page {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
</style>
<div
id="password-page"
class="{{ section.settings.bg_color }}"
style="--bs-bg-opacity: {{ section.settings.bg_opacity | append: '%' }};">
<div
class="container"
style="max-width: {{ section.settings.max_width }}px;">
<a
class="navbar-brand d-block text-center p-0 mb-8"
href="{{ routes.root_url }}">
{% if section.settings.logo %}
{% assign logo_height_x2 = section.settings.logo_height | times: 2 %}
<img
class="img-fluid"
src="{{ section.settings.logo | image_url: height: logo_height_x2 }}"
alt="{{ shop.name }}"
width="{{ section.settings.logo_height | times: section.settings.logo.aspect_ratio | round }}"
height="{{ section.settings.logo_height }}"
loading="lazy">
{% else %}
<span class="fs-1">
{{ shop.name }}
</span>
{% endif %}
</a>
<div class="card shadow-sm">
<div class="card-body">
{% unless shop.password_message == blank %}
<p class="lead text-center">
{{ shop.password_message }}
</p>
{% endunless %}
{% form 'storefront_password' %}
{{ form.errors | default_errors }}
<div class="form-floating mb-4">
<input
class="form-control"
type="password"
name="password"
placeholder="{{ 'general.password_page.input_label' | t }}">
<label for="newsletter-input-email">
{{ 'general.password_page.input_label' | t }}
</label>
</div>
<button class="btn btn-primary w-100" type="submit">
{{ 'general.password_page.btn_label' | t }}
</button>
{% endform %}
</div>
</div>
{% if section.settings.social_icons %}
<div class="social-icons-wrapper text-center mt-5">
{% render 'social-icons', icon_size: 18 %}
</div>
{% endif %}
</div>
</div>
{% schema %}
{
"name": "Password",
"tag": "section",
"settings": [
{
"type": "select",
"id": "bg_color",
"label": "Background color",
"default": "bg-body",
"options": [
{ "value": "bg-primary", "label": "Primary" },
{ "value": "bg-secondary", "label": "Secondary" },
{ "value": "bg-body", "label": "Body" },
{ "value": "bg-white", "label": "White" }
]
},
{
"type": "range",
"id": "bg_opacity",
"label": "Background opacity",
"min": 0,
"max": 100,
"step": 1,
"default": 100,
"unit": "%"
},
{
"type": "text",
"id": "max_width",
"label": "Max-width (px)",
"default": "600"
},
{
"type": "header",
"content": "Logo"
},
{
"type": "image_picker",
"id": "logo",
"label": "Logo"
},
{
"type": "range",
"id": "logo_height",
"label": "Logo height",
"min": 20,
"max": 100,
"step": 2,
"default": 40
},
{
"type": "checkbox",
"id": "social_icons",
"label": "Show social icons",
"default": true
}
],
"templates": ["password"],
"presets": [
{
"name": "Password",
"category": "Password"
}
]
}
{% 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 行