Skip to content

feat: Add Shopify Theme Development Best Practices guide #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zjtdzyx
Copy link

@zjtdzyx zjtdzyx commented Jul 8, 2025

feat: Add Shopify Theme Development Best Practices guide

Description

This Pull Request introduces a comprehensive Best Practices guide for Shopify Theme Development. As an active Shopify theme developer, I've identified a need within the community for a centralized resource that outlines effective strategies for building robust, performant, and maintainable Shopify themes.

This guide covers key areas of Shopify theme development, including:

  • Project Structure: Guidelines for organizing files and folders.
  • Liquid Templating: Best practices for writing efficient and maintainable Liquid code.
  • JavaScript Development: Modern approaches to integrating JavaScript into themes.
  • CSS/SCSS Styling: Recommendations for scalable and maintainable stylesheets.
  • Sections and Blocks: How to effectively utilize Shopify's Section architecture for flexibility and reusability.
  • Performance Optimization: Strategies to ensure themes are fast and responsive.
  • Accessibility (A11y): Emphasizing the importance of inclusive design.
  • Maintenance and Scalability: Tips for long-term theme health.
  • Quality and Testing: Approaches to ensure the reliability of theme code.

Motivation

While the "Awesome Cursor Rules" project primarily focuses on development efficiency through cursor rules, I believe including best practices guides aligns with the broader goal of empowering developers. This guide serves as a valuable resource that can:

  • Improve Code Quality: Encourage developers to write cleaner, more efficient, and more maintainable Shopify theme code.
  • Enhance Development Workflow: Provide a structured approach to theme development, reducing common pitfalls.
  • Benefit the Community: Offer a go-to reference for both new and experienced Shopify theme developers looking to elevate their craft.

I've structured this guide to be clear, actionable, and easy to follow, mirroring the format of other best practices documents within the broader developer community.

Related Issue

Closes #125

Checklist

  • I have read the project's contributing guidelines.
  • My contribution adheres to the project's coding standards.
  • I have tested the new content for clarity and accuracy.
  • My commit message follows the Conventional Commits specification.

Thank you for considering this contribution. I believe it will be a valuable addition to the repository.

Summary by CodeRabbit

  • Documentation
    • Introduced a comprehensive best practices guideline for Shopify theme development, covering Liquid templating, JavaScript, CSS/SCSS, sections and blocks, performance, accessibility, maintenance, scalability, and quality testing.

Copy link

coderabbitai bot commented Jul 8, 2025

Walkthrough

A new best practices guideline document for Shopify theme development has been added. The document provides recommendations on Liquid templating, JavaScript, CSS/SCSS, sections and blocks, performance, accessibility, maintenance, scalability, and quality testing, as well as conventions for project structure and coding standards.

Changes

File(s) Change Summary
rules-new/shopify-theme-dev-liquid.mdc Added a comprehensive best practices guideline for Shopify theme development using Liquid.

Sequence Diagram(s)

No sequence diagram generated, as the change is documentation only.

Assessment against linked issues

Objective Addressed Explanation
Provide cursor rules/best practices for Shopify theme development (Liquid) (#125)

Poem

A rabbit hopped through Liquid code,
Leaving best practices wherever it strode.
With CSS and JS tidy and neat,
Accessibility and speed can't be beat!
Now Shopify themes will truly gleam—
Thanks to this guide, a developer’s dream!
🐇✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
rules-new/shopify-theme-dev-liquid.mdc (3)

17-24: Strengthen Liquid guidance with pagination & loop limits
Mention paginate and limit/offset attributes on for loops. These are the primary tools to curb excessive object iteration and DB hits, complementing the existing N+1 bullet.


25-31: Add note on Shopify-specific JS lifecycle & removing jQuery reliance
Most themes still ship jQuery; recommending its removal (or at least no new dependencies) would modernise the advice. Also add a bullet on listening for shopify:section/block load/unload events so modules initialise correctly in the Theme Editor.


57-63: Expand A11y section to reference WCAG 2.1 and landmark roles
Calling out WCAG success criteria (e.g., 1.4.3 contrast, 2.4.1 bypass blocks) plus header/main/nav/footer landmarks and skip-links gives developers testable targets.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42ac7cf and f067a73.

📒 Files selected for processing (1)
  • rules-new/shopify-theme-dev-liquid.mdc (1 hunks)

Comment on lines +1 to +4
---
description: Best practices for Shopify theme development with Liquid, JavaScript, and CSS
globs:**/*.liquid, assets/*.js, assets/*.css, sections/*.liquid, snippets/*.liquid, templates/**/*.liquid
---
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Front-matter globs field is not valid YAML – parsing will fail
The key/value pair is missing a space after the colon and should be an array (each glob quoted or indented). Broken front-matter prevents the rule engine or any static-site generator from reading the metadata.

-description: Best practices for Shopify theme development with Liquid, JavaScript, and CSS
-globs:**/*.liquid, assets/*.js, assets/*.css, sections/*.liquid, snippets/*.liquid, templates/**/*.liquid
+description: Best practices for Shopify theme development with Liquid, JavaScript, and CSS
+globs:
+  - "**/*.liquid"
+  - "assets/*.js"
+  - "assets/*.css"
+  - "sections/*.liquid"
+  - "snippets/*.liquid"
+  - "templates/**/*.liquid"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
---
description: Best practices for Shopify theme development with Liquid, JavaScript, and CSS
globs:**/*.liquid, assets/*.js, assets/*.css, sections/*.liquid, snippets/*.liquid, templates/**/*.liquid
---
---
description: Best practices for Shopify theme development with Liquid, JavaScript, and CSS
globs:
- "**/*.liquid"
- "assets/*.js"
- "assets/*.css"
- "sections/*.liquid"
- "snippets/*.liquid"
- "templates/**/*.liquid"
---
🤖 Prompt for AI Agents
In rules-new/shopify-theme-dev-liquid.mdc at lines 1 to 4, the front-matter
globs field is not valid YAML because it lacks a space after the colon and is
not formatted as an array. Fix this by adding a space after the colon and
converting the globs value into a properly indented YAML array with each glob
pattern quoted or listed on separate lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cursor rules for shopify theme dev(liquid)
1 participant