How to add a custom metaobject or metafield to my homepage

I’m looking for help on how to add a metaobject to my homepage through custom coding. I’m able to add the metaobject (via a custom metafield) to other pages, but not my homepage, so I’ve been told I need to custom code it.

Could anyone provide assistance - I cannot find any resources on this.

Here’s what I’ve done so far:

  1. I created a metaobject called “customer_testimonials.”
  2. I created a metafield on ‘pages’ using the same name (“customer_testimonials”) and linked it to the metaobject as a list.
  3. I was able to add the metaobject entries to other ‘pages’ successfully - by updating the metafield at the bottom of the page in settings > pages
  4. However, when I attempt to connect the same metaobject to a block on my homepage using the theme editor, the ‘Connect dynamic source’ icon does not appear, even though it works fine on other landing pages with the same section block. I assume this is because I have not updated the metafield for the homepage because the homepage is not in settings > pages

I can confirm the following:

  • I’m using an Online Store 2.0 theme, which supports dynamic sources.
  • Storefront access is enabled for the metaobject.
  • The section block is compatible, as I’ve successfully connected metafields on other pages.

Can anyone help?

HI @JasminBod :waving_hand: off the top of my head try adding to a store level market metafield to see if it will surface as a dynamic source in a section for the index template.

:thinking: anecdote: market metafields sometimes seem to take a while to refresh in the cache before they show up so for a while it may seem like market dynamic sources don’t work.

Otherwise you need to directly access it either by just putting the relevant liquid-code in the settings*, or hardcoding/customizing the variables in the sections code itself.

*dynamic sources end result is just liquid output tags {{ pages.metafield.namespace.key }} , try copy & paste to see the accessor chain.

dynamic sources facilitate finding metafields(mfs) with a GUI through inference of certain mf types

Hi @PaulNewton Thank you for your response!

I have managed to to add the store level marketmetafield (attached to a metaobject list) and it IS now appearing as a source on the homepage (in the theme editor) :raising_hands: . HOWEVER, although I can now add the dynamic metaobject values into the theme editor (i.e. name, quote, image), they are not showing any content - I guess this is because the metafield has not been populated for the homepage (as it would be for page or product metafields for example).

How do I populate the market metafield for the homepage?

Isn’t that metafield just needing to reference the same metaobject like all the other metafields

But where do I choose the metaobjects to display? currently 0 have been selected.

On a usual ‘page’ I would go to online store > pages > [page name] and populate the metafield at the bottom of the page. But how do I populate a market metafield for the homepage so I can tell it which metaobjects to display?

Check the markets admin?

If this even feasible to get a markets > metafield > that references a metaobject > to be usable in a index page > as a dynamic source > for some section.

The combinations of system here makes things fuzzy to tell if it’s even possible without code customizations you’ve got to step through everything or others have to burn time replicating the setup.

If you hit the deadend here contact support to clarify things, and or set a feature request for the use case of these systems working together more intuitively.