Create one page WordPress template with anchor links in menu

Create onepage.php template with this code:

<?php
/* Template name: One page */
get_header();
//set some variables
$args = array(
	'sort_order' => 'ASC',
	'sort_column' => 'menu_order', //post_title
	'hierarchical' => 1,
	'exclude' => '',
	'child_of' => 0,
	'parent' => -1,
	'exclude_tree' => '',
	'number' => '',
	'offset' => 0,
	'post_type' => 'page',
	'post_status' => 'publish'
);
	
//get all the pages on your site
$pages = get_pages($args);

foreach ($pages as $page_data) {
$content = apply_filters('the_content', $page_data->post_content);
$title = $page_data->post_title;
$slug = $page_data->post_name;
$pageid=$page_data->ID;

//Put a container around every page's content
echo "<div class='$slug' id='$pageid'><a name='$slug'></a>";

//Heading and Content
echo "<h2>$title</h2>";
echo $content;
echo "</div>";
}

get_footer(); // Loads the footer.php template. ?>

Add this to heade.php between <nav> and </nav> (or wherever you want to display the menu with anchor links.)

<?php //get all the pages on your site
    $pages = get_pages();
    //get the pages used in the menu. See codex for more options http://codex.wordpress.org/Function_Reference/get_pages
    $pagemenu = get_pages( array( 'sort_column' => 'menu_order', 'sort_order' => 'asc', 'parent'=> '0') ); 
	//Menu goes on top of page
	echo"<ul id='nav' class='nav menu'>";
			foreach ($pagemenu as $pagemenu_data) {
			 	$caption = $pagemenu_data->post_title;
				$pageslug = $pagemenu_data->post_name;
		//Start Page Menu
		echo "<li class='$pageslug'><a href='#$pageslug'>$caption</a></li>\n";
		}
	echo"</ul>";
?>

Create page (for example: Home) and attach Onepage template to it. Make that page as Default static front page (Settings -> Reading):

 

Code from WordPress Community forum users wearitwell and invot.