Zid Docs
  1. Getting Started with Zid Themes
Zid Docs
  • Merchant API
    • Start Here 🚀
    • Overview to Zid Apps
    • Authorization
    • Responses
    • Webhooks
    • Rate Limiting
    • APIs
      • Orders
        • Update Order by ID
        • Get Order Credit Notes
        • Get Order by ID
        • List of Orders
      • Reverse Orders
        • Reverse Order Reasons
        • Create Reverse Orders
        • Create Reverse Orders Waybill
        • Add Reverse Order Reasons
      • Carts
        • Get Abandoned Cart Details
        • List Abandoned Carts
      • Products
        • Managing Products
          • Get a Product by ID
          • Retrieve a list of products
          • Create a new product
          • Update an existing product.
          • Bulk update of products using their IDs or SKUs
          • Delete a product.
          • Product Setting
          • List Product Reviews
        • Digital Vouchers
          • Product Vouchers
          • Order Voucher
          • Add Product Voucher
          • Import Vouchers
          • Export Vouchers
          • Update Product Voucher
          • Remove Product Voucher
        • Product Categories
          • Get Single Category Details
          • Get all categories
          • Create Store Category
          • Update a Store Category
          • Add a product to a certain category
          • Publish/Unpublish a Category
          • Detach Category from All Products
          • Remove Category from Product
        • Product Badge
          • Product Badge
        • Product Attributes
          • Get Product Attributes
          • Get Product Attributes
          • Retrieve a product attribute
          • Add a New Product Attribute
          • Add a New Product Attribute
          • Update a product attribute
          • Delete a product attribute
        • Product Attribute Presets
          • Get attribute presets
          • Create Attribute Preset
          • Update Attribute Preset
          • Delete an attribute preset
        • Product Customizations
          • Add Product Variants
          • Insert Custom Options to a Product
          • Insert Custom User-Input Fields to a Product
        • Product Manual Sorting
          • Set Custom Product Order
          • Reset the manual sorting of all products
        • Product Images
          • Get List of images of a product.
          • Add an image to a product
          • Update a product Image Order
          • Delete a product image
        • Product Notifications
          • Availability Notification Stats
          • Availability Notifications Settings
          • List Availability Notifications
          • Add Availability Notification
          • Save Availability Notifications Settings
          • Manually Send Availability Notification Email
          • Export Availability Notifications
        • Product Import
          • Email All Products to Store Owner
          • Import Products via CSV or xlsx File
        • Product Stock (Multi-Inventory)
          • Get Product Stock by ID
          • List Product Stocks
          • Add Product Stock
          • Update Single Product Stock
          • Bulk Update Product Stocks
        • Product Questions & Answers
          • Get Question
          • Get Answer
          • Get All Questions
          • List Question Answers
          • Create Question
          • Create Answer
          • Update Question
          • Update Answer
          • Delete Question
          • Delete Answer
        • Product Reviews
          • List Reviews
          • New Reviews Total
          • Change Review Status
          • Bulk Change all Review Statuses
          • Delete Review
          • Import Product Reviews
          • Reply to Review
          • Delete Reply
          • Update Reply to Review
        • Digital Products
          • Create Downloadable Product
          • Generate an Upload URL
          • Upload File to S3
          • Create Product Downloadables
          • Get Product Downloadables
          • Delete Product Downloadables
          • Get Store Downloadables
          • Create Store Downloadables
          • Delete Store Downloadables
      • Inventories
        • Get Store Location by ID
        • List Store Locations
        • Add a New Location
        • Update a Location by ID
        • Update Products Stock by Location ID
      • Shipping
        • List Store Delivery Options
        • Add Shipping Option
      • Marketing
        • Gift Cards
          • Get Store Settings
          • Add gift card to the cart
          • Update Store Settings
          • Upload gift card designs
          • Remove gift card from the cart
        • Coupons
          • Create a New Coupon
          • List Coupons
          • Get Coupon Details
          • Update Coupon
          • Delete Coupon
        • Bundle Offers
          • Retrieve all Bundle Offers
        • Loyalty Program
          • Customer Wallet
          • Customer Points
          • Loyalty Program Points per Order
          • Store Loyalty Status
          • Redemption Methods
          • Cashback Rules
          • Add Redemption to Cart
          • Remove Redemption from Cart
          • Info Page
          • Loyalty Program Activation
          • Loyalty Status
          • Set Points Expiration
          • Cashback Rule Method Update
          • Cashback Rule Method Update Status
          • Add Points Redemption Method
          • Update Points Redemption Method
          • Delete Points Redemption Method
          • Toggle Redemption Method Status
          • Show Loyalty Points Info for Specific Customer
          • Customer Profile
          • List Data
          • Customer Points History
          • Info Page - Managers
          • Update Info Page
          • Adjust Customer Points
      • Customers
        • List of Customers
        • Get Customer by ID
      • Store Settings
        • 📄 User Roles and Permissions
        • Get Manager's Profile
        • Get VAT Settings
        • List of Payment Method
      • Countries and Cities
        • Retrieve Store Operating Countries
        • Retrieve Cities by Country ID
        • Countries List
      • Webhook
        • List of Webhooks
        • Create a Webhook
        • Delete a Webhook by OriginalId
        • Delete a Webhook by Subscriber
    • Store Events
      • Order
      • Product
      • Abandoned Cart
      • Customer
      • Product Category
  • App API
    • Create your First App
    • Embedded Apps
    • App Scripts
    • App Events
    • App Subscription
      • Get Subscription Details
      • Update Usage-Based Charges
  • Themes
    • 🚨 Important Update: Zid Themes
    • Adding Video URL Feature to Third-Party Themes
    • Landing Page Development
    • Getting Started with Zid Themes
      • Introduction to Theme Development
      • Manage your Themes
      • Building Themes in Zid
      • Theme File Structure
      • Twig Syntax and Features
      • Zid Theme Packager
    • Templates
      • Layout
      • Home Page
      • Products
      • Cart
      • Store Language and Currency
    • Settings Schema
      • Text
      • Number
      • Text-Area
      • Select
      • Radio Buttons
      • Checkbox
      • Range
      • Color
      • Image
      • Product
      • Category
      • List
      • Fieldset
    • Code Snippets
      • Apple Pay Quick Checkout
      • Custom CSS Injection
      • Displaying the Store's Business Center Logo
      • Customizing Copyright Text
      • Store's Main Navigation Menu
      • Customer Wishlist
      • Products
        • Products Badges
        • Product Ratings
        • Remaining Product Stock
        • Sold Items Count
        • Product Filtration by Attributes
        • Grouped Products
        • Product Questions & Answers
        • Product Restock Notfication
      • SEO
        • Images alt text
        • Themes SEO Marketing Tags
      • Marketing
        • Metafields
        • Gift Feature
        • Loyalty Program
    • Zid Themes Library: API Integration
      • Products
      • Product Categories
      • Cart
      • Blog
      • Customer
      • Store Settings
    • Data Reference
      • Locals
      • Store
      • Cart
      • Product
      • Products List
      • Category
      • Categories List
      • Session
      • FAQs
      • Customer
      • Blogs
      • Page
      • Main Menu
      • Main Navigation Menu
      • Request
      • Orders
      • Addresses
      • Store Payment Methods
      • Store Shipping Methods
      • Store Banks
      • Asset URL
      • Header Meta Tags
      • Loyalty pogram Wallet
    • Themes CLI
      • CLI Authentication
      • Theme Create
      • Theme Package
      • Theme Update
      • Themes List
      • Theme Preview
  1. Getting Started with Zid Themes

Theme File Structure

The structure of a Zid theme is designed to be intuitive and flexible, enabling easy customization and effective management of your theme's components. Grasping this structure is key to successfully implementing both the visual and functional aspects of your theme.

Contents of a Zid Theme#

A Zid theme is composed of a series of Twig Templates, each housed within a .twig file serving a distinct role in the theme's design and functionality.
In Addition to Twig Templates, a Zid theme contains static assets, and optional JSON files for localization. The following hierarchy of files represent a valid Zid theme.
layout.twig: Master layout for theme structure.
header.twig: Website header section.
footer.twig: Website footer section.
templates (Directory containing page-specific templates)
404.twig: Custom 404 error page.
home.twig: Homepage layout.
search.twig: Search results layout.
products.twig: Multiple product listings.
product.twig: Single product details.
reviews.twig: Customer reviews section.
categories.twig: All product categories overview.
category.twig: Individual category details.
blogs.twig: Blog post summaries.
blog.twig: Single blog post details.
faqs.twig: FAQ section.
cart.twig: Shopping cart interface.
shipping-and-payments.twig: Shipping and payment options.
account-addresses.twig: User account addresses management.
account-orders.twig: User's order history.
account-profile.twig: User profile and settings.
modules (Modular Twig snippets for template integration)
common (Reusable Twig templates across the theme)
locals (Localization files, e.g., 'messages.en_US.yaml')
assets (Static files: CSS, JavaScript, images)
Note: For your theme to function correctly, the files and folders listed above must be included in your theme project folder.

What are Twig Templates and Data?#

To understand what a Twig Template is, it is useful to draw parallels. For instance, in the context of Content Management Systems (CMS), Twig Templates resemble the common concept of web templates. In the Model-View-Controller (MVC) architecture, Twig Templates resemble the View component. Twig Templates are responsible for the presentation logic in a web application. They are infused with Twig Components, including variables and function calls. Utilizing the Twig engine, these templates are dynamically merged with relevant data to render the web pages.
In this documentation, the term data specifically refers to the structured content and variables passed into Twig templates, which are essential for customizing and displaying dynamic information on your web pages. This can include everything from user-specific details to product information. Various schemas of data objects are detailed for reference in the next chapter.
For an in-depth understanding of Twig Templates, you can explore the official Twig documentation.

A Detailed Look at Twig Templates and Folders of a Zid Theme#

There are three types of Twig Templates in a Zid theme: Global, Page-specific, and Component templates. We explain those three below followed by an explanation of other folders shown in the Zid theme.

Global Templates#

These three .twig files lying in the root directory are site-wide templates. They form the foundational layout of your theme, used across all pages.
layout.twig: The backbone of your theme, encapsulating other templates.
header.twig: Defines the header, including navigation and branding.
footer.twig: Outlines the footer, containing contact info, and additional links.

Page-Specific Templates#

Each .twig file in the templates directory corresponds to a specific type of page or component within the store. We call these Page Templates. Each Page Template is designed to render a distinct part of the store, such as product listings (products.twig) or the shopping cart interface (cart.twig).
All templates outlined above under the templates directory are mandatory.

Twig Components/Modules#

In addition to the main templates, the theme may include smaller, reusable Twig Components or Modules (stored in the modules folder). These components add specific functionalities to the Twig Templates and can be used across different parts of the theme.
Think of these as global functions that you can call from within any other Twig Template/Component.
To learn more about which Twig components we support, jump to the next section about Twig Syntax and Features.

Directories with Optional Contents#

The remaining directories are mandatory and must exist in your root directory. However, it is optional whether they contain any files.
common: Common elements like banners or calls-to-action.
locals: Contains .json or .yaml files for theme localization and internationalization, e.g., messages.en_US.yaml. Please resist the urge to correct the spelling mistake in locals, otherwise the theme will not compile correctly.
locals: This directory, intentionally named 'locals' (yes, it's not a typo!), contains .json or .yaml files for theme localization and internationalization, such as messages.en_US.yaml. Remember, keeping the 'locals' spelling as-is is crucial for the correct compilation of the theme.
assets: Houses your theme's static files, such as stylesheets, scripts, and images. Zid permits the following file types for assets: .js, .ts, .css, .scss, .map, .png, .jpg, .jpeg, .gif, .svg, .woff, .woff2, .otf, .ttf, .eot.
Please ensure all template files and directories follow the naming conventions and file structure indicated. Correct implementation will ensure seamless integration with the Zid storefront and an optimal experience for end-users.
Modified at 2024-12-05 07:56:37
Previous
Building Themes in Zid
Next
Twig Syntax and Features
Built with