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.
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.
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.
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.
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.
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.