Best practices for reusing global "blocks" of static data in multiple templates for multiple pages?

So, I’m still only a couple of days into understanding how Shopify works.

I feel confident with metafields, Theme sections with presets and and how to get specific sections to appear on specific products using metafields as filters. I also undestand how to use a single Theme section with dynamic data populated from metafields in different products.

What I still don’t fully comprehend is how to make reusable Theme sections with static data easily shared between templates (products and pages).

Let’s say I want to create an “Image with text” like below. And I want to use for both products and pages. Maybe something about my company or how products are made.

I have managed to create a Theme section with prefilled data (Title, text and image) using Presets:

SvenSvensson_2-1644909915784.png

But I see two disadvantages here.

  1. The more content you have the more bloated the Theme sections list will be.

  2. The only way I know of how to create a preset is by using the code editor.

Is there any other way?

Can I store a preset based on the values I added in the the GUI (Customize)?

Thanks!

Alternatively you may want to try storing the static data in “global” metafields. If you create a metafield for the shop object, you’ll be able to access the data from different resources (products, collections, pages) with a single line of Liquid code:

{{ shop.metafields.namespace.key.value }}

By the way, you can generate the Liquid code snippet for specific metafield with our app:

Thanks for your reply!
So the only to create those fields today is through the API or by using your app, or similar?

And with your app I can create and set values to metafields in one single place?

Is it easy to organize the values in case I have for example 20 global blocks with title, text and image for each of them? If I create an image fields, can I use the image browser to pick the images? Or do I have to get the shopify url for the image? The idea is that the customer should be able to do this themselves.

Hi Sven,

Sure, you can create an unlimited number of “global” metafields to represent your static blocks.
In case you’d like to use different metafields for title, text and image (which implies that you’ll have a bunch of metafields, I guess), you’ll be able to navigate through the records easily thanks to the advanced data filtering and sorting features:

And, of course, you won’t have to paste the image URLs manually as our app has a built-in image browser to select the files from the Shopify data storage:

Let me know if you have any additional questions!

Hi!
I have now installed the app and added some metafields for the shop object.

Can I access them in the UI? Or do I have to use them programatically?

Hi Sven,

Great, nice to hear that!

You may want to follow this step-by-step tutorial to display the shop metafields on the product page. It’s pretty much the same as displaying the product metafields, except for the fact that you have to copy the Liquid code as shown in my initial reply.

Thanks! I’ll check it out!