Correctly handle hidden pages in the custom navigation module (see #5832)