Solved

Shopify CLI: Pushing a theme overwrites settings and section data

jnicol
Shopify Partner
7 0 13

I am using Shopify 2.0 CLI for the first time, and have noticed that "shopify theme push" will overwrite settings_data.json, and reset (remove) any dynamic sections that the merchant has added to their store.

This seems dangerous, since pushing a theme might nuke a merchant's customisations.

Am I doing it wrong? Is there a safer way to push a theme?

On a related note, where does Shopify store section data? For instance if a merchant adds dynamic sections to their homepage where is that data stored, since it's not in settings_data.json?

Accepted Solution (1)

Eleftheria
Visitor
1 1 3

This is an accepted solution.

Hello,

Before making changes to an already set store, pull your theme,  modify anything you want and then push. You can also duplicate the store for safety before doing any of these things

View solution in original post

Replies 12 (12)

CarolineK
Visitor
1 0 0

I am experiencing the same issue. It's really problematic as I'll customize a bunch of settings in the store --- but every time I run `shopify theme push` it resets them back to the default.

Eleftheria
Visitor
1 1 3

This is an accepted solution.

Hello,

Before making changes to an already set store, pull your theme,  modify anything you want and then push. You can also duplicate the store for safety before doing any of these things

jnicol
Shopify Partner
7 0 13

Thanks, pulling first works 🙂

I figured out that section customizations are stored in the relevant template's JSON file, in the "settings" key. Synchronising those files from remote > local is the step I was missing.

jasewarner
Shopify Partner
1 0 9

Before making changes to an already set store, pull your theme,  modify anything you want and then push.

This is fine, just so long as whoever is working on the theme remembers to do so first. This approach, in Online Store 2.0, seems to be pretty high-risk, to me at least.

jnicol
Shopify Partner
7 0 13

This is fine, just so long as whoever is working on the theme remembers to do so first. This approach, in Online Store 2.0, seems to be pretty high-risk, to me at least.

Agreed. I would prefer that Shopify CLI had an equivalent to Theme Kit's "watch" command, which watched for any changes made to your local files, and automatically pushed updates to your theme in the connected Shopify store. Instead of pushing the entire theme, it would push only the modified file.

Theme Kit's "deploy" command also accepted a single file name as a flag, so the developer could push just one file.

If either of those options were added to Shopify CLI it would eliminate - or at least dramatically reduce - the likelihood of accidentally overwriting data.

jnicol
Shopify Partner
7 0 13

Shopify CLI 2.3.0 includes an --ignore option which partially addresses the issue described in this thread.

https://github.com/Shopify/shopify-cli/pull/1479

Ex.:

shopify theme push --ignore "config/*.json"

The ignore option is merged with any pattern defined in .shopifyignore

mickaelriga
Tourist
4 0 3

Yes but now there are other json files for the templates. It becomes tedious. I would appreciate a shortcut which ignores all "Customise" related things in one go. Or maybe we can do "**/*.json" as an argument?... regardless I would feel more confortable if we had a way to deal with conflicts instead of blindly overwrite everything. Because it means we need to ask the client to not touch anything after we pull.

Roger_McEffort
Shopify Partner
47 0 7

`theme watch` is perfect. They just had to remove it. 

mickaelriga
Tourist
4 0 3

Yes I have a similar issue and when you version your code with Git, it is even trickier. This mix of code and data feels dangerous.

hellodaylight
Shopify Partner
1 0 1

The only problem with this method is what if my client makes changes while I'm editing the templates? I have overwritten my clients' changes several times now. I'd like someone to explain exactly the process of editing templates, styles, and js from a developer standpoint, while a client or editor is working on content. I really don't like the mixing of content + build in the new CLI.

Roger_McEffort
Shopify Partner
47 0 7

Sadly I think the only solution for now is to completely ignore the 'templates' folder or adding to your .shopifyignore

shopify theme push --ignore "config/**/*.json" --ignore "templates/**/*.json"