Sign in

Random Posts in Static sites

  • This topic has 4 replies, 5 voices, and was last updated 1 month, 3 weeks ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1036
    Avatar photo[anonymous]

    Hello, is there a way to make the website show random post every time the users open it?

    #1037
    Avatar photoTomasz Dziuda

    Hi,

    Due nature of the static websites it is not possible to achieve in the output HTML. The only solution can be creating JSON object with posts to load and then display them randomly, but as I suppose it won’t work for the search engine crawlers as it will be a content dynamically generated by JS script.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #2758
    Avatar photoabacigalupe

    Is there any way to show randomly @config.custom.uploadImage1 or @config.custom.uploadImage2 on a div?

    My code is:

    —————–
    <div id=”bannersLPost” class=”bannersLPost”>
    <figure>
    <img
    class=”lazyload”
    {{#checkIf @config.custom.lazyLoadEffect ‘!==’ “lqip” }}
    src=”{{@config.custom.uploadBanner1}}”
    {{else}}
    data-src=”{{@config.custom.uploadBanner1}}”
    {{/checkIf}}
    {{responsiveSrcSet @config.custom.uploadBanner1}}
    {{responsiveSizes}}>
    </figure></div>

    ———-

    I have @ config.custom.uploadBanner1 and @ config.custom.uploadBanner2 … I want to show randomly banner1 or banner2.

    How could i achieve that?

    Thanks a lot in advanced.

    #10439
    Avatar photocandidexmedia

    Did you ever figure this out? Somebody else had the same question: https://forum.getpublii.com/topic/show-random-posts/

    #10445
    Avatar photofinrik
    candidexmedia wrote:

    Did you ever figure this out? Somebody else had the same question: https://forum.getpublii.com/topic/show-random-posts/

    I am the questioner from the other post.

    In my case I don’t need random posts on every reload. I want random posts on export/update of the web page. Ideally, I could randomize the array with a helper function. It would be even better if there was a parameter for this in Publii. Is basically only 10 lines of code 😉

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.