YOCaml a framework used to describe static site generator
31 points by xvw
31 points by xvw
This sounds interesting but I gave up trying to find an example of what the description of a website looks like.
I once made a static site generator called 'sitio' that was fully imperative and I think that's the best model, but haven't seen anything like that ever anywhere else, so I was thinking that this could be it but now I'm not sure.
The big idea is that you just write code that calls generatePage(path, template, content) and that's it. If you have a directory of Markdown files you read those, iterate, parse and call generatePage(), if you want something else that doesn't fit a normal website you generate that other page too. All very clear and explicit and infinitely flexible.
This is not a requirementbut in 'sitio' each page was also a React component so it was prerendered but could also be dynamic at runtime simultaneously.
Is there anything like this out there?
This sounds interesting but I gave up trying to find an example of what the description of a website looks like.
There's some examples in the repository if that's what you're after: https://github.com/xhtmlboi/yocaml/tree/main/examples (would be nice if there was an easier way to get to these from the site).
I don’t think that scales to larger sites unless there’s some dependency tracking magic or intelligent caching you’re not mentioning.
In fact, there is some deps tracking magic and caching system (only for dynamic deps) and the low level design is described here (if you are interested): https://lobste.rs/s/riexk8/unpragmatic_static_blog_generator_ocaml
The implementation looks like Build System a la Carte (https://www.cambridge.org/core/journals/journal-of-functional-programming/article/build-systems-a-la-carte-theory-and-practice/097CE52C750E69BD16B78C318754C7A4) with a dedicated API for dealing with filesystem and handling metadata (so less generic) but we (our set of user including me) does not face to any particular limits for the moment :)
Thanks! I was replying to another comment though :)
It is great to see more implementations taking inspiration from BSALC! Keep up the great work!
Incidentally, I am curious: Is there anything that would prevent someone from using this to generate something other than a website? For instance, could someone twist it into a compilation tool for a programming project?
In the tutorial generator we use it, YOCaml, for building the library that highlight the code (from TextMate Grammars to OCaml JSON repr) but at least, for OCaml, dune, the build system is very good and very generic.
Since it is mostly a tutorial the website is built step by step. Do you think that we should give a direct example before explaining each step ?
Probably, yes, or just get rid of some of the steps. I think the tutorial is very slow and doesn't allow the reader to find the point in the tutorial that works for them. For example, there's a monad tutorial, an explanation of how effects work, and a guide on how to use Dune and OPAM before we get to use the actual framework, and even then the introduction is how paths work and how to copy files.
I'm very interested in this project because it looks like exactly the sort of thing I've been looking for recently, but at around that point I bailed and figured I'd come back to the project if I really needed it!
I'd suggest moving the stuff on OPAM, effects and monads, and anything else that is educational-focused into an "advanced" section that the reader can peruse if they need to understand these topics in more detail. For the installation, I'd give the bare minimum of instructions for a relatively opinionated setup (i.e. "here's the command to create a local switch, here's the dune config you need to get started, copy that in place and run this command, now you're ready to go"), and then dive into a practical example that lets the user actually do something - maybe convert an index.md file into an index.html file. That all could be done in maybe even a single page, and then there's still a lot for the reader to understand, but they can start seeing some results already.
The other thing I noticed was that there was no sidebar, at least on the mobile view. This makes it difficult to see what's coming next, and how deep into the process you currently are. It also makes it more difficult to skip around - if I'm comfortable with one part of the tutorial, or it's not really relevant to me, then I like to be able to move on ahead and maybe come back to a section later.
All that said, this project sounds really cool, and I will surely try it out next time the urge comes to redo my own personal website.
Thanks for the feedback ! For the sidebar, yes, we should invest time on the mobile version ! (There is a sidebar on the desktop version)