using header.php while having original metatags on each page...?

by 2 replies
3
On my static pages I usually use php includes, which means I have a header.php and a footer.php file.
In my header.php I have everything from <! DOCTYPE ... until the <div> tag that goes right before my content (ie. <! DOCTYPe ...><html><head>meta etc</head><body><div etc>)

I realized, that this causes the meta tags to be the same on each of my pages, so now I'm wondering if there's a way to work around this.

I'm thinking that I could include <! DOCTYPE ...> <html><head> meta etc... </head> in each of my individual .php files, and then just insert the php include tag after </head>.
I would of course edit my header.php accordingly, and remove everything before <body>..

I need header.php as it includes my menu.

Do you think this sounds like a good idea, or is there a smarter way to achieve the same result?
#programming #headerphp #metatags #original #page
  • Example:

    $title = "My custom title";
    $keywords = "custom keywords";

    include("header.php");

    ...and in header.php, you echo $title and $keywords at the right places.

    Another option is to create a function, so it becomes includeheader("My Custom Title","custom keywords");

    Just two of many ways to do it
    • [ 1 ] Thanks
  • Method 1 (echo...) is exactly what I was looking for!!
    Works perfectly, thanks a lot!! =)

Next Topics on Trending Feed