Added check to make sure 'dates' is not None

This prevents error in case the site consists only of pages and no articles.