snoogy
Social Collaboration Coordinator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
Getting Started
For example, you have this simple meta data in your header.php template.
Code:
In order to create a unique meta data for another page and reuse your header.php template, do the ff.
1. Assign variables for your meta tag in your header.php.
Example:
2. Edit the value of the variable in each landing page by declaring the variable first before declaring your header.php.
Example:
You should now be able to create unique meta tags for your pages.
That ends this tutorial. Happy Coding :)
For example, you have this simple meta data in your header.php template.
- <!DOCTYPE html>
- <html
>
- <head
>
- <meta
charset
=
"utf-8"
>
- <meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0"
>
- <meta
name
=
"url"
content
=
"Your Site Url here"
>
- <meta
name
=
"description"
content
=
"Your Site description here"
>
- <meta
name
=
"keywords"
content
=
"Your set of keywords for the page "
>
- <meta
name
=
"author"
content
=
"John Doe"
>
- ................................
- <title
>
How to Dynamically Change Meta Tags in every Pages using PHP</
title
>
- <!-- css and scripts here -->
- </
head
>
Code:
In order to create a unique meta data for another page and reuse your header.php template, do the ff.
1. Assign variables for your meta tag in your header.php.
Example:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="description" content="<?php
echo
$description
;
?>
">
- ............................
- <title>How to Dynamically Change Meta Tags in every Pages using PHP</title>
- <!-- css and scripts here -->
- </head>
2. Edit the value of the variable in each landing page by declaring the variable first before declaring your header.php.
Example:
- <?php
- $description
=
"Your site description here"
;
- include
'header.php'
;
- ?>
You should now be able to create unique meta tags for your pages.
That ends this tutorial. Happy Coding :)