Refactored the index.php file and page.php file to cut down the amount of code displayed in index.php