More Descriptive SEO Titles

Every web page has a title tag in the head element of the HTML. It lets everybody know what the web page is about including Google. And even when a web page is shared on social media like Facebook. Facebook adds the title into the Facebook post. So it's important that those titles accurately reflect what the web page is about.

Today we are going to make sure that title is as descriptive and accurate as possible. Because right now the title is the same on every blog, category, and home page.

A title can have up to 3 parts separated by pipes. The first part is the name of the website. The second part will be the category of the topic. The third part will be the title of the blog.

So we will 2 variables for each route. One for the category and one for the blog title. Then we will attach it to Klien's $service variable. Then we can use those variables in the header view.

Now I can use the data I passed in for the category and title using $this keyword. So the title tag looks like this.

<title>Zach The Web Guy | <?= $this->category['title'] ?> | <?= $this->title ?></title>

Now when I share my blog I have great titles that let the human and bot readers understand what the web page is about. Now the blog not only looks professional but has improved SEO performance.

Comments