How to make a page skeleton?
The same header for all your pages
When your site will grow, you will have several different services for pages which will often contain the same header informations.
A great solutions to avoid code copy-pasting of these recurrent informations are to make a page skeleton function:
let skeleton body_content =
Lwt.return
(html
(head (title (txt "Page Title")) [])
(body body_content)))
So when you define your pages, you just call this skeleton with the content of the page as an argument:
Example.register ~service:main
(fun () () -> skeleton [p [txt "Hello World!"]])
This method can also be adapted to add elements on all your pages, like a header, a footer and a menu.
Module Eliom_tools has a predefined function for this:
Eliom_tools.D.html
~title:"ex"
~css:[["css"; "ex.css"]]
(body [h2 [txt "Welcome to Ocsigen!"]]