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 =
       (head (title (pcdata "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 [pcdata "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:

  ~css:[["css"; "ex.css"]]
  (body [h2 [pcdata "Welcome to Ocsigen!"]]