HTML / PHP: Which parts of an HTML head can be saved in a separate file -
i new html , hope can me this.
i trying set website code every page saved separate php file. since these pages use same document head , includes i remove as possible of pages , save in separate includes file (header.php
) can include using php.
my current head looks follows , since same on pages have saved in separate header.php file , use <?php include "header.php"; ?>
on single pages.
can tell me parts of should remain on single pages proper setup , if should changed or added here ?
note: jquery , js included separately in footer.
my php (header file):
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="author" content="john doe" /> <meta name="description" content="created: 2015-06" /> <base href="http://www.myurl.com" target="_self" /> <!-- css --> <link rel="stylesheet" type="text/css" href="includes/styles.css" /> <!-- css - font awesome --> <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" /> <title>my page</title> </head> <body> <div class="wrapper"> <!-- ... -->
your top head file (top_head.php):
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <?php if(isset($page_author)){ ?> <meta name="author" content="<?php echo $page_author; ?>" /> <?php } ?> <?php if(isset($page_description)){ ?> <meta name="description" content="created: 2015-06" /> <?php } ?> <!-- css --> <link rel="stylesheet" type="text/css" href="includes/styles.css" /> <!-- css - font awesome --> <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" /> <title><?php echo $page_title; ?></title>
your current header file:
<?php $page_title = 'hello'; $page_description = 'this beautiful description'; ?> <?php include("top_head.php"); ?> </head> <body> <div class="wrapper"> <!-- ... -->
Comments
Post a Comment