Search code examples
jekyll

Preserving the state of pages per session


I have a demo website built using Jekyll that compares the outputs of different APIs for benchmarking purposes. The website has a total of three pages, and in each page, you have a submission form that takes in a text string, runs it against a few apis, do some preprocessing on the results, and then shows them in a table underneath it. The table is cumulative, and each new request results get added at the very top row.

One issue I am facing is that when you switch to a different page within the website itself, and then return to the previous one, the table of results is completely wiped out, and you start with a clean slate. My question is: using Jekyll, is there a way to preserve the state of each page as you switch between them per a given session?


Solution

  • Jekyll is a static page generator, so it's not possible to preserve state of pages on the server.

    But you can use browser local storage according to docs: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage