Make sure a page has a type before accessing page['type']

Otherwise we get a `KeyError` which may not be super informative.