Hi There, sorry if this is easy but how do you create reusable content for use in the 2.0 editor?
Everyone suggests Metafields but they can’t have defaults as far as I can tell - is that correct? And because reusable content blocks often need to fit within editor blocks (and in different places product depending), hard-coding them can be painful. And if they are hard-coded, editors no longer have easy access and hard-coded content tends to make theme updates more painful.
e.g. Say you have product-based content that applies to many but not all your products. It seems you have to create a product Metafield, manually add identical content to each product, and if that content needs to appear on different page-types (pages, blogs etc) you have to duplicate the Metafields all over again.
Then when content needs updating (as it always does!) you have to manually update the Metafields one at a time, is that correct? If so, Metafields seem great for small snippets of unique data but impractical for reusable content.
Or are we missing something basic? Any help very much appreciated! Cheers, Ben
It will depend on the content to determine the best method, but it sounds like you should use page, product, blog templates etc.
You can create a unique template which contains the info that needs to be shown for multiple pages. Then assign it to your products, or pages as needed. That way you don’t need to fill out the info for every page/product but just do it once for the template instead.
But obviously this requires people comfortable with coding to setup and maintain.
Also, this method intermingles content with theme code which we’re finding increasingly painful with the way themes are updated on Shopify because there doesn’t seem to be an obvious/easy way of separating customisations from the core theme (that we can find).
Hi Ben,
What you describe above (rendering a snippet based on specific conditions) is another effective way to customize products or other pages in your store. The issue for most with this method is that you need to understand where to place the code and how to write it. For example:
If your goal is to avoid having to use the “Edit Code” function or adding to/editing your theme files, I would recommend using the Theme Editor as I mentioned in my original reply. You are correct, this method will also create new code files in your theme, but you will not need to write or edit any of this code it will be generated automatically. All changes to the Templates would be mad in the built-in Theme Editor, then you simply assign them to your products or pages.
As far as I know these are really the two options for changing or adding unique content: Edit The Code Yourself OR Use Shopify’s Built In Options (Theme Editor)
It will really depend on how many content sections you need, if it is going to be more than what is possible using the theme editor (25 sections per template, which is a lot most pages will only need 3-8) then I would start using snippets to render the content. Otherwise I’d recommend doing what you can with the Theme Editor, it will be much simpler overall since you won’t have to mess around with code.