Set with something like:
current_page.add_metadata( {'body_class' => 'blog'} )
Read with
current_page.metadata['body_class']
There are four predefined ‘categories’ of data/metadata: options, locals, page and blocks. You can use them like this:
current_page.add_metadata( :options => { :layout => 'sea' } )
Sometimes it is possible to use these predefined categories to overwrite stuff set in front matter (ie the stuff that’s normally accessed with current_page.data
). For example,
current_page.add_metadata :options => { :layout => layout }
will override the setting of layout in front matter. But my experience is that this is needs to be checked from case to case, since it depends on if the developer has remembered to check not just data but also metadata (for example, you can not use this to overwrite the page title in the blog module).
Note that Middleman sometimes uses symbols and sometimes strings as keys.