Changing metas for each page in PHP Website

妖精的绣舞 提交于 2020-04-11 15:26:35

问题



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.


回答1:


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.




回答2:


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

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

And inside your header.php file can do that for all the different meta tags you have defined:

<meta name="keywords" content="<?php echo $meta['keywords']; ?>" />
<meta name="description" content="<?php echo $meta['description']; ?>" />
...



回答3:


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


来源:https://stackoverflow.com/questions/15063273/changing-metas-for-each-page-in-php-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!