skip to Main Content

Instead of putting all files in a place in the asset folder, I want to use CSS files in CSS folder, JS files in js folder and images in images folder. Then Include them in the asset folder, so that I can maintain the files easily.

I know Shopify doesn’t support any sub-directories within the asset folder. But is there any trick to do that?

2

Answers


  1. Unfortunately, this is not something currently supported by Shopify (As of 14/Sept/2017)

    I tried making sub-folders both at the root of my dev theme and in the asset folder of my dev theme in a few different ways, including through Shopify’s ThemeKit editor, but Shopify did not let me create the folder.

    Attempting to create sub-folders in the normal theme editor in the store (by naming an asset subfolder/filename) generates the error message: Theme files may not be stored in subfolders

    Shopify’s normal theme editor groups files by types so that they appear close together, and apparently that’s as much as Shopify is giving us right now.

    Login or Signup to reply.
  2. According to a Shopify employee. This is currently not possible and the reason is due to a limitation of the CDN they use. See that post here.

    Regardless, it’s not good practice to have source files in the assets folder. Look into the Shopify Slate tool. It’s a theme scaffold and command line interface that helps keep your project structure organized.

    You can organize your assets (both CSS and JavaScript) as source files with directory structures in a manner similar to this:

    styles/
      global/
      modules/
      settings
      tools/
      vendor/
    

    The command line tool takes care of compiling all the source files into one CSS/JS file! As a consequence, you don’t need to worry about including the respective files with <link> or <script> tags because it’s all taken care of already!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search