We can easily use our own template by following few steps as mentioned below.
1. Select the Template from left menu and click on button Backup/Restore as shown below.
# For sites running on a port other than 80 RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteCond %{SERVER_PORT} !^80$ RewriteRule ^/(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R] # And for a site running on port 80 RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$
# For sites running on a port other than 80
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R]
# And for a site running on port 80
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [L,R]
<head>
? Let’s dive right in.<head>
dynamic!index.php
, contact.php
, what have you, will reference the same header.php
file via an include
statement:<?php include('header.php'); ?>
header.php
should also be included in the file being requested. This way, we don’t have to write a lot of the same HTML on every content page. Instead, we have this one static file from which we can pull the necessary code. Note that theheader.php
file doesn’t necessarily contain only the HTML <head>
. Generally, it will include any code that is reusable at the top of the HTML document throughout the website (including the logo, navigation, banner, etc.). Let’s look at an example of code we might find in header.php
:
<html lang="en">
<head>
<title>Page Title Here</title>
<meta name="description" content="Meta description goes here.">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
. . .
echo
construct to place the necessary page-level variables(which we haven’t yet created) in the right spots in header.php
.
<html lang="en">
<head>
<title><?php echo $pageTitle; ?></title>
<meta name="description" content="<?php echo $pageDescription; ?>">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
. . .
<head>
. If the condition within the parentheses is met, then the code within the brackets ({ ... }
) is executed.
<html lang="en">
<head>
<title><?php echo $pageTitle; ?></title>
<meta name="description" content="<?php echo $pageDescription; ?>">
<?php
// If canonical URL is specified, include canonical link element
if($pageCanonical)
{
echo '<link rel="canonical" href="' . $pageCanonical . '">';
}
// If meta robots content is specified, include robots meta tag
if($pageRobots)
{
echo '<meta name="robots" content="' . $pageRobots . '">';
}
?>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
. . .
<head>
with elements that rely on page-defined variables, we’ve done most of the “hard” work. Let’s move on to defining these page-specific variables.$pageTitle
and $pageDescription
) before our include(header.php)
statement. Ideally, we would write in some conditionals to catch cases where these variables aren’t defined; but for now, we’ll just be extra careful to define them on each page. We have the option of defining two additional variables ($pageCanonical
and $pageRobots
), as well. To define a variable, we use the syntax: $variable = "This is a string";
. Let’s go ahead and assign values to all four of our variables for the home page. We’ll be working with the index.php
file. (The topic of our site is Orange Widgets).
<?php
// Define variables for SEO
$pageTitle = 'Orange Widgets | The Best Orange Widgets';
$pageDescription = 'Visit AwesomeOrangeWidgets.com to find the best orange widgets in all the lands (Oz included).';
$pageCanonical = 'http://www.awesomeorangewidgets.com/';
// We don't want the search engines to see our website just yet
$pageRobots = 'noindex,nofollow';
// Include header file
include('header.php');
. . .
?>
index.php
.
<html lang="en">
<head>
<title>Orange Widgets | The Best Orange Widgets</title>
<meta name="description" content="Visit AwesomeOrangeWidgets.com to find the best orange widgets in all the lands (Oz included).">
<link rel="canonical" href="http://www.awesomeorangewidgets.com/">
<meta name="robots" content="noindex,nofollow">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
. . .
<head>
elements we’ve discussed. What takes minutes to implement could yield years’ of worth.