Changing metas for each page in PHP Website

2019-02-20 21:53发布


Take a look at this: How to make webpages with the same design. I used it to make a website called X Phoenix. When I type X Phoenix on google, it doesn't come on top, although i've put it on google webmasters and it's been 4 months. It doesn't come anywhere I can see on Google Search. On this pdf, it's written that use different keywords, titles, and descriptions for all pages. But in my website, i've used the method in which i put the head and a few other things from body in a file called the header.php and things below my content in footer.php, then in a page for ex. home.php, I put:

<?php include('header.php'); ?>
my text
<?php include('footer.php'); ?>

My metas are in the header, so how am I to change it in each page.
How to write keywords i.e xphoenix,x,phoenix,f1, etc.
Also tell me other ways to make my website on top of google and make it look better good.
Please give me some info on sitemaps and how to make them.
If I have the name: team x phoenix, should I write team,x,phoenix or team x phoenix in keywords.

3条回答
萌系小妹纸
2楼-- · 2019-02-20 21:58

You can define your different meta tags on each of your pages by this:

$meta['keywords'] = "Keyoword, more words, ...";
$mtea['description'] = "...";
<?php include('header.php'); ?>
my text
<?php include('footer.php'); ?>

And inside your header.php-file you're doing that for all the different meta tags you have defined:

<meta name="keywords" content="<?php echo $meta['keywords']; ?>" />
<meta name="description" content="<?php echo $mtea['description']; ?>" />
...
查看更多
男人必须洒脱
3楼-- · 2019-02-20 21:59

To my own experience, I store my meta descriptions and keywords in the database respectively to the page which contains it. Then I call it to the header dynamically.

- page_id             int(11) auto increment
- page_title          varchar(250)  Not Null
- name                varcar(250)  Not Null
- meta_description    text
- meta_keywords       text
- is_published        tinyint(1)  Not Null
- is_deleted          tinyint(1)  Not Null
查看更多
ゆ 、 Hurt°
4楼-- · 2019-02-20 22:22

You could do this for example:

In you home.php

$meta1 = 'My meta tag text';
include('header.php');
echo 'my text';
include('footer.php');

In your header.php you could do this:

<meta name="description" content="<?php echo $meta1; ?>">
  • For seo you can check this link: SEO
  • For a sitemap generator you can look here: Sitemap

But i think it is best if you'd just use google for this.

查看更多
登录 后发表回答