Seconded, PHP provides great flexibility
I maintain a site with over 100, mainly static, pages. Every page starts with a require() function call to load all the standard HTML headers, title blocks and menu and ends with another require() to generate standard footer data and insert the final the and tags. If I need to modify the menus I only need to update a single file for the change to be implemented across the entire site.
The small number of dynamic pages are created from a MySQL database using PHP's MySQL extensions.
There's excellent documentation for PHP at