Auto-generate SEO friendly titles for game profile pages #2

Open
opened 2024-01-14 14:10:59 -06:00 by jimmyb · 1 comment
Owner

Originally posted by josh87

I was just looking at the way the tiles appear across the site and they are almost always the same.

For example, look at this game profile page for The Last of Us on Playstation 3: http://myvideogamelist.com/gameprofile/1096/The_Last_of_Us

That's not very descriptive for search engines like Google and Bing. Having keywords in the page title is very important for users to be able to find the site in search.

Imagine if someone went to Google and typed in "the last of us playstation 3" as a search query. Gamestop shows up with a page on their site that has the same keywords in the title.

We should be able to do the same thing relatively easy across thousands of pages on the site by simply altering the code in the header.php file so it can generate dynamic page titles. Then, we could set the page tiles dynamically for every game by using the game name and platform.

For example, some variable like $page_title could be set before header.php is loaded:

$game = Game::fetch($gameid);
$page_title = $game->name . "" . $game->getPlatform() . "";
/* code... */
require 'header.php';

Then, inside header.php we can check for the $page_title and use that, while also falling back to a default if no title is set:

<?php
if (!isset($page_title)) {
    $page_title = 'MyVideoGameList.com | Track Your Video Games!';
}
?>
<title><?php echo $page_title; ?></title>
**Originally posted by josh87** I was just looking at the way the tiles appear across the site and they are almost always the same. For example, look at this game profile page for The Last of Us on Playstation 3: http://myvideogamelist.com/gameprofile/1096/The_Last_of_Us <title>MyVideoGameList.com | Track Your Video Games!</title> That's not very descriptive for search engines like Google and Bing. Having keywords in the page title is very important for users to be able to find the site in search. Imagine if someone went to Google and typed in "the last of us playstation 3" as a search query. Gamestop shows up with a page on their site that has the same keywords in the title. We should be able to do the same thing relatively easy across thousands of pages on the site by simply altering the code in the `header.php` file so it can generate dynamic page titles. Then, we could set the page tiles dynamically for every game by using the game name and platform. For example, some variable like `$page_title` could be set before `header.php` is loaded: ``` php $game = Game::fetch($gameid); $page_title = $game->name . "" . $game->getPlatform() . ""; /* code... */ require 'header.php'; ``` Then, inside `header.php` we can check for the `$page_title` and use that, while also falling back to a default if no title is set: ``` php <?php if (!isset($page_title)) { $page_title = 'MyVideoGameList.com | Track Your Video Games!'; } ?> <title><?php echo $page_title; ?></title> ```
jimmyb added the
component: backend
type: improvement
labels 2024-01-14 14:10:59 -06:00
Author
Owner

Originally posted by josh87

Looks like $page_title could be used for this actually. I'm not seeing it being used anywhere else:

josh@ubuntu-server:~/public_html/myvideogamelist.com$ git branch
* development
  master
josh@ubuntu-server:~/public_html/myvideogamelist.com$ git pull
Already up-to-date.
josh@ubuntu-server:~/public_html/myvideogamelist.com$ grep -ri '$page_title' .
josh@ubuntu-server:~/public_html/myvideogamelist.com$
**Originally posted by josh87** Looks like `$page_title` could be used for this actually. I'm not seeing it being used anywhere else: ``` bash josh@ubuntu-server:~/public_html/myvideogamelist.com$ git branch * development master josh@ubuntu-server:~/public_html/myvideogamelist.com$ git pull Already up-to-date. josh@ubuntu-server:~/public_html/myvideogamelist.com$ grep -ri '$page_title' . josh@ubuntu-server:~/public_html/myvideogamelist.com$ ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: MyVideoGameList/myvideogamelist.com#2
No description provided.