Jump to content

Meta data programmatically


phppup
Go to solution Solved by gizmola,

Recommended Posts

I'm not sure whether I'm becoming overindulgent or a real developer, so please advise me.

I have several webpages for a new website. I am well acquainted with them and their content.

As I began planning to publish these pages, I realized I could probably utilize an array to include meta data for bots and search engines.

My thinking was something like:

for ($I=0; $I<count($meta); $I++){
if ($page.I){
echo $meta[I]
}
}

 

I'm concerned with the effectiveness of doing this.

Will bots and crawlers see it as legitimate and valid the same as if each page had "hand written" meta data?

Or will it flag it as illegitimate or miss it, thereby hurting the pages placement in search results?

Not much more to provide since I'm asking the question BEFORE attempting the code.

Thanks

 

 

 

Link to comment
Share on other sites

  • Solution

Search engines just look at the final http response data.  They have no visibility into the internals of how a page is rendered.

There is no problem doing what you want to do, and in fact many cms's, forums and frameworks do this exact thing.

Just to be clear, meta tag keywords are ignored by google, so you may or may not want to include those in your page rendering.

Link to comment
Share on other sites

@gizmola With all due respect, I don't think google is the ONLY search engine on earth.  (Sorry, not a fan of theirs, but still fond of you.  LOL)

Are there any less popular meta tags that I should use (beyond the usual list) or recommended settings to be aware of?

Edited by phppup
Link to comment
Share on other sites

For what it's worth, Google also isn't the only search engine that ignores the keywords meta tag when it comes to ranking. Unfortunately, there's too many people willing to pack those meta tags with irrelevant content in order to boost their rankings.

Do you consider the description meta tag as part of the "usual list"? The meta tag can be useful for pages that don't have a description paragraph for search engines to display in their results listing. 

Link to comment
Share on other sites

Google by far generates the most organic search traffic, so it's best to focus on them, as most of the other search engines follow their lead in terms of how they score a page internally.

Also the google search console is an excellent tool for getting an idea of what is going on with the indexing of your site.  You should make sure you've gone through the steps to insure that every site you control is registered within the tool.

The title tag is important.  There's a rule of thumb being "12 words/70 character max".  Google indexes only the 12 words, weighted towards the first 12.  It will also only display up to 70 characters. 

The description tag is important, only so much as it will be displayed when it comes up in a search result.  This is where you can "sell a user" on the relevancy of that page, since the description will show up with the result.

Keywords and description are both things that google no longer uses, and were used in the past by people trying to game SEO, by putting in descriptions for pages that don't have relevant content to match the description, or a long list of keywords they "wished" the page in question was relevant for.  Any decent search engine these days, parses the content of the page and uses a high degree of sophistication in determining relevance.  You aren't going to fool anyone by listing a bunch of key words in the meta tag. 

Since Google hasn't even looked at them in years, many sites omit them at this point, and if that was a significant concern, you would see discussion of that.

Typically if you look at SEO discussion, the main thing that comes up beyond proper use of meta tags is h1's, canonical vs. non-canonical versions of a page, and how to handle those, and having a sitemap (that you re-generate/add to whenever you add a new page to your site.) 

For indexing pages and internal link collections (for example a page on a blog that has all articles for a particular year, or a page in a catalog where you have all products within a particular category, the robots tag is a good one, and has advantages over using a robots.txt.  You don't want non canonical versions of the same page, or pages that could lead to indexing of a non-canonical version along with the canonical version as this has the potential to reduce the overall score for the canonical page.  Pages like that should typically include the robots tag.

<meta name="robots" content="noindex, nofollow" />

More about that here.  

If you have video content then you want a video sitemap or mrss feed as described here

I know that not all of this is directly related to your meta data question, but hopefully still generally related and useful.

 

Link to comment
Share on other sites

@cyberRobot Yes, I do consider the description tag as one of the "usual."

I discovered a meta for security and refresh that I am unfamiliar with and uncertain about.

As for you saying

Quote

too many people willing to pack those meta tags

Yes, that was me from way back when.  I suppose I owe an apology to everyone that I effected. (although I never got too crazy and NEVER used irrelevant terms)

Link to comment
Share on other sites

You really want to focus on the ones that are programmatic.  This is why using a template system like twig or even (back in the old days) smarty is so valuable.  Typically this is because you have some sort of database structure where you are entering and configuring attributes related to a page. 

The title tag is the prime example, even though it is not a meta tag.

You also should have a canonical link for all pages, even when that is on a canonical page (pointing back to itself).  For example, if you look at the yahoo home page, you find this in the head.

<link rel="canonical" href="https://www.yahoo.com/">

As for the meta tags they have the general form of (name, content) so a helper function could be:

function makeMeta($name, $content): string
{
	return '<meta name="' . $name . '" content="' . $content . '">' . PHP_EOL;
}

 

Link to comment
Share on other sites

@gizmola Thanks.

And yes.  Again, I haven't started to write the actual code, but that was my thought process (especially since so many of the tags fit such a similar format.

I guess I've actually come quite a way (thanks to those that have helped me HERE).

*i wonder if it's time to change my username???!?*

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.