I have created a dynamic web site with php and mysql. There are only one 3 meta tags which settled in header.php for common usage. So, I don’t know should I use those meta tags for each pages. For instance, I have and offers.php page. Should I use title and description for this page. If it’s compulsory, blog posts that I created with dynamic php codes and seo link, its keywords are placed under meta keywords. I’m right?
Hi onurturali welcome to the forum
AFAIK, all pages need a
<title> to be valid. Preferably each would be unique and the best appropriate for the page. But if you can’t do that, it won’t break your site if they are not.
<meta> descriptions are good to have. Without them, search engines will usually do what they can with what they get. With them, search engines might use them.
<meta> keywords are useless and can be safely ignored. Not that at this time you need to panic and spend a lot of time removing them. But it isn’t worth spending any time adding them.
I have a common header.php and pass variables for title, canonical and description.
Another important tag is viewport. View the source of this forum page and notice the meta tags.
I cannot check at the moment because using a tablet.
The major search engines recommend that each page on your site has a unique title and meta description. This can easily be achieved with php if you have data stored somewhere to populate those tags.
In your html template you may have something like:-
<link rel="stylesheet" type="text/css" href="css/style.css"> <title><?php echo $title ?></title> <meta name="description" content="<?php echo $description ?>"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name=viewport content="width=device-width, initial-scale=1"> <link rel="canonical" href="http://www.example.com<?php echo $canonical ?>">
Those variables may be set in your controller script, pulling the data from wherever you are keeping it.
That may be pulled from a database or explicitly set within the controller:-
$title = "Home Page" ;
From the DB:-
$title = htmlspecialchars($row['pagetitle']) ;
I understand that there are static meta tags which placed in header.php and contents are dynamic. So, my meta tag contents in header.php are main, to create unique meta tags I should use php variables in each pages, right? I can not figure it out that php variables in header.php and php variables in each pages are not overlap?
Yes, similar to my example above.
I’m not sure what you mean by that. Can you explain further?
To adding Meta Tags into PHP coding
<?php include('header.php'); ?> <meta name="keywords" content="key, word"> <meta name="description" content="blah blah blah."> <title>Title</title>
Welcome to the forums, @fabrictimeuk.
I’m not sure what you’re trying to demonstrate with that code, but the opening
<html> tag should come before the
Also, as already explained, using the keyword meta tag is a waste of time.
We’re happy to have you contribute, but please take time to explain, rather than simply posting a code snippet, and where you do post code, please ensure it’s complete and valid.
I see you’ve now edited your post to remove the
<html> tag, and you’ve added
Your code is not, however, an example of adding meta tags in PHP. All it shows is using a PHP include (content unknown) before standard HTML meta tags.
Perhaps you could explain your thinking more clearly.
(Editing a post after somebody has replied and commented on it is not helpful, as it causes confusion.)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.