add support for page ordering

also fixes bug in media imports when a file is used in multiple HTML
files.