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

by LK
2 replies
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?
#headerphp #metatags #original #page
  • Profile picture of the author Manfred Ekblad

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


    ...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
    {{ DiscussionBoard.errors[2147430].message }}
  • Profile picture of the author LK
    Method 1 (echo...) is exactly what I was looking for!!
    Works perfectly, thanks a lot!! =)
    LK's Adsense Experience - no shenanigans, just a simple blog~
    {{ DiscussionBoard.errors[2147465].message }}

Trending Topics