Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrandon Gibbs
9,636 PointsOk, maybe this will be answered later as more info is given... but it's about SEO....
With all of this code being slimmed down (no pun intended) ... How does this affect Google, Bing, etc being able to crawl the page and index sites for search rankings?
I am guessing that the meta info will remain either in the .html files or in it's own .php file that will be called later.
I am just curious about when it comes to making sure that best practices on the HTML side are not being overlooked by Google and Bing when using PHP.
Any SEO guys or gals out there care to take a second to explain why/if this is still SEO friendly?
1 Answer
thomascawthorn
22,986 PointsRemember you're only refactoring behind the scenes - the pages are still compiled into the same html you originally had.
When it comes to customising meta information, that's easier than it seems! When you call a template (e.g. home.twig), it generally extends a layout (e.g. layout.twig). layout.twig will contain the head, nav, footer etc.. All the basic html stuff. home.twig will contain the customised content for the home page. Nothing new so far!
In layout.twig, you can actually define multiple placeholders (called 'blocks' in twig, 'sections' in laravel). This means you can do something like this (laravel example - just take a look at the twig docs or copy and paste what you have already - it's a very slightly different syntax!)
Layout
<!doctype>
<html>
<head>
<title>@yield('pageTitle')</title>
<meta name="Description" content="@yield('pageDescription')">
</head>
<body>
@yield('content')
</body>
</html>
Extending template:
@section('pageTitle')This is where the page title goes! @stop
@section('pageDescription')This is where the page description goes! @stop
@section('content')
<h1>This is where amazing content goes!</h1>
@stop
This way you can totally customise your meta information on a per template basis. As a side note, I believe I'm right in saying Google doesn't index by page title or description anymore, but this information will show in search results. It instead looks at page content - so make sure your content follows good seo practices :)
Try the SEO Basics Course for more info.
Brandon Gibbs
9,636 PointsBrandon Gibbs
9,636 PointsOk, that makes sense. I get that it was being populated as html on the front end, I guess I was just over thinking it at bit. I've seen source code on a lot of sites lately that don't have the same html footprint that one would expect. They have structures as you'd expect like <body> etc... but the content between seems to be "pointing" to code and content in other files.... THAT sort of printout, I believe, would be problematic as there's not much for Google to crawl...
But yes, Google still does factor in title and meta information, but it is not as heavily weighted as it once was... because people can not be trusted. lol. Now content is a MAJOR part of it... proper structure is important as well, good use of keywords without keyword stuffing, and natural links are important as well. i.e. comments from other users from sources like FB comments, YouTube video comments, Disqus and other commenting plugins that attach a profile / link to the 'username' or profile of the person commenting.
I'm a bit of an SEO guy, but as with code there is always something in your field that you don't know... until you know it. Now that I'm venturing into coding... it presents some questions that I never thought to seek before when I was using just static HTML sites.
Thank you very much for your time and you answer.