Add

Lorem ipsum

Lorem ipsum

A
A
A
CMS & Logic

4 views

4 min

How to Display Random CMS Items in Webflow

Learn how to display CMS items randomly in Webflow: JavaScript shuffle and a random order field.

In this tutorial, Sandro, co-founder of the Gemeos Webflow agency, shows you how to display CMS items randomly in Webflow.

MethodTrue randomnessReload required
Random number field + sortNo (fixed at publish time)Yes (republish)
JavaScript shuffle (this tutorial)Yes (on every load)No
Finsweet CMS Load + shuffleYesNo

Method 1: JavaScript shuffle on load

This method shuffles the items already displayed in the DOM on every page load. Add a cms-list class to your Collection List Wrapper, then add this script to the body:

function shuffleList(list) {
var items = Array.from(list.children);
items.sort(function() { return Math.random() - 0.5; });
items.forEach(function(item) { list.appendChild(item); });
}
document.addEventListener('DOMContentLoaded', function() {
var list = document.querySelector('.cms-list .w-dyn-items');
if (list) shuffleList(list);
});

Method 2: Random order field in the CMS

Add a Number field called "Order" to your collection. Fill it with random values (1 to 1000). Sort your Collection List by this field in ascending order. The result will be "random" but fixed until the next republish. Simple and no code required.

3. Limit the number of items displayed

To display only 3 random items out of 50, set the Collection List limit to 3 in Webflow. The JavaScript shuffle will mix the items before Webflow applies the limit: you'll still see 3 different items on every reload.

good to know

The Math.random() - 0.5 algorithm used in Array.sort() is not a truly uniform random shuffle (Fisher-Yates bias). For a perfectly random shuffle, use the Fisher-Yates algorithm: for (let i = items.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [items[i], items[j]] = [items[j], items[i]]; }. The difference is imperceptible when displaying article suggestions, but it matters for applications where fairness is at stake.

Conclusion

Random display improves content discovery. Use cases:

  • "Suggested articles" section at the bottom of a blog post
  • Client testimonials displayed in different ways
  • Highlighting different products on each visit

Good to know

Heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet consectetur.

Lorem ipsum dolor sit amet consectetur. Aliquam orci sagittis dignissim sapien praesent donec.

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...