creative designer

If you'd been paying attention to the Liquid documentation changes you would have seen something new appear to the Liquid Objects page (under articles). It highlights how to directly reference an article in Liquid - something that previously had to be handled with JavaScript.

Like some of the releases on the Shopify documentation this is something that deserved way more attention than it got. Hacking articles to do cool things has been around for as long as the blogs have. 

Having partners and developers shift off those JS hacks and move over to Liquid is a solid win for everyone. It's also damn cool.

Example.

Let's take a look at a live example that shows some code looping over a few predefined articles. The article values are stored in a metafield, and I've made a point of grabbing some articles from different blogs. Check out the Showing specific blog posts in a blog post post. (That was fun to type). 

The Code

The code for this is super basic with the logic largely:

  • get the metafield
  • split the value
  • loop over the array
  • clean the whitespace from each array during the loop
  • use that to reference an article, and show a title on the page.
grabbing the liquid snippet...

Like to work with me?

Let's talk