Displaying Random Testimonials on site build

Hello

I am looking to have a data file called testimonials.yaml and would like various sections on my site to display random ones. Where do I start? is there an easy way to do this.

Jordan

Not your answer, and not sure how up/outdated it might be, but the random “at every time the page is generated, but not every time the page is viewed” argument seems pretty strong…

cheers i have found a solution - its not totally random but it works for what I need

{% assign hours= site.time | date: “%H” | plus:1 %}
{% assign random = page.title.size | plus: hours | modulo: site.data.reviews.size %}
div class=“small-12 medium-6 large-3 columns column-block”>
div class=“card”>
div class=“card-section”>
p>{{ site.data.reviews[random].text } }/p>
/div>
div class=“card-break”>
div class=“card-section”>
p>{{ site.data.reviews[random].person}} /p>
/div>
/div>
/div>

How large is the data file? I’d be tempted to use it to create a json file and lazy load the random data with an ajax call to the json file.

1 Like

It’s not massive and it’s just simple text but I will look into this for better performance

1 Like