Lighthouse - Optimize your website, Part 2: SEO

Last week we took a look into what — and how — Lighthouse can help us with, when working with optimization of your website. This week we will look at the Search Engine Optimization (SEO) part of a Lighthouse report.

For the purpose of this series, I’ve created a really bad looking — and performing — website (with one single page) just to enable me to show how things can easily be fixed.

You can see the website here: http://test.frontenddesigner.dk/

Let’s just jump right into it — here’s the a screenshot of the Lighthouse report

(if you’re not familiar with Lighthouse yet, I recommend you take a look at their Github repo: https://github.com/GoogleChrome/lighthouse or read the Introduction from Google here: https://developer.chrome.com/docs/lighthouse/overview)

Lighthouse SEO report.

As you can see, we’ve got some serious issues here — as we only get a score of 17 / 100. Let’s take a look at each part of the report.

Crawling and indexing

We’ve got a single issue in the Crawling and indexing part:

  • Page is blocked from indexing

This means that Google can’t index the content on the page — so this page will likely never be indexed by Google. If Google can’t index the content — the page will never be shown as a search result on Google.

The reason the content can’t be indexed is pretty simple. I’ve got this HTML inside the tags:

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

The 'noindex, nofollow' value simply indicates (to robots), that we don’t want them to index or follow any links on the page. If we remove the tag completely, we won’t have any issues with indexing of the page.

Content best practices

In this part of the report we’ve got several issues to fix:

  • Document doesn’t have a title element

  • Document does not have a meta description

  • Links do not have descriptive text

  • Image elements do not have [alt] attribute

  • Document doesn’t have a valid hreflang

  • Document does not have a valid rel=canonical

Let’s have a look at how we fix all these issues.

Title & description

We need a title and description for the page. A title and description is often used to show the headline and the descriptive text for a search result in Google. Sometimes Google will change the descriptive text, if it doesn’t match the users search term — or if the description is simply not good enough. I’m not a SEO-expert — and I haven’t got a description on my site yet (I know — I’ll fix it 😉). But Google still creates a good description for me:

Google preview of "Frontend Designer Blog" frontpage.

To set the title and description, all we need is these two elements inside the head:

<title>Title for the page</title>
<meta name="description" content="Description for the page" />

If you put the two tags on your page, Lighthouse won’t pinpoint any issues here. This does not mean that your page is optimized perfectly regarding SEO — Lighthouse knows nothing about your content and what you’re optimizing for. Lighthouse just tells us if there’s any technical issues with the page — and how we can fix them.

Descriptive text for links

“Click here”. This is the easy — and very oldschool way — of linking to something on the web. If you look at the link out of context, you’ll have no idea of where you’ll get redirected to, when clicking the link.

Imagine a road-sign saying “Take this exit” without no info about where you’ll end up, if you actually take that exit.

That’s why you have to do descriptive texts, instead of “Click here”, “Read more” etc. A title attribute for the link is not enough to make Lighthouse happy. So just get to it — make those descriptions! 😉 (I’m really bad at it — so I guess I’ll have to get started as well)

On the test page I created I had this link:

<a href="https://frontenddesigner.dk" target="_blank" title="Frontend Designer Blog - a blog about web development.">
	click here
	<br />
	<svg style="width: 100px; height: auto;" id="uuid-184db287-0fec-467f-a5ac-aa74f71086d9" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 301.033 239.41"><defs><linearGradient id="uuid-8788d676-c3d5-4b27-b6ab-121f6ccba695" x1="0" y1="119.705' x2='301.033" y2="119.705" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#167260" /><stop offset="1" stop-color="#1faa8f" /></linearGradient></defs><path d="m238.11,21.329l19.32,31.024-132.276.119c-10.482.021-20.015,5.365-25.502,14.296l-24.749,40.286c-2.307,3.755-2.399,8.292-.249,12.138,2.151,3.846,6.065,5.69,10.518,5.691h100.006l-19.188,30.493c-8.244,13.305-22.509,21.82-38.208,21.852H33.638c-1.712.02-3.295,1.467-4.195,2.923L0,227.801l.014-78.967c.003-17.703,4.937-35.012,14.268-50.057L62.32,21.323C70.577,8.009,84.86.052,100.526.04l49.68-.04,49.693.04c15.666.012,29.948,7.968,38.21,21.289ZM62.752,218.039c8.256,13.382,22.573,21.372,38.297,21.372h99.561c15.709,0,30.019-7.978,38.277-21.34l24.09-38.973,23.726-38.146c9.375-15.073,14.33-32.423,14.33-50.173V11.699l-29.562,47.35c-.241.386-.531.733-.857,1.033-.918,1.404-2.487,2.262-4.18,2.263l-141.266.127c-6.982.014-13.338,3.577-16.996,9.531l-24.749,40.286c-.349.568-.4,1.057-.156,1.494.311.556,1.006.889,1.86.889h130.718c4.412,0,8.453,2.342,10.547,6.111,2.083,3.75,1.949,8.201-.358,11.908l-24.824,39.883c-5.514,8.859-15.035,14.147-25.47,14.148h-.01l-50.265-.018-76.787.901c.813,6.327,2.964,12.429,6.327,17.879l7.747,12.555Z" style="fill:url(#uuid-8788d676-c3d5-4b27-b6ab-121f6ccba695); stroke-width:0px;"/></svg>
</a>

It’s fixed putting a great descriptive text as the link text — and not only as the title:

<a href="https://frontenddesigner.dk" target="_blank" title="Frontend Designer Blog - a blog about web development.">
	Frontend Designer Blog - a blog about web development.
	<br />
	<svg style="width: 100px; height: auto;" id="uuid-184db287-0fec-467f-a5ac-aa74f71086d9" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 301.033 239.41"><defs><linearGradient id="uuid-8788d676-c3d5-4b27-b6ab-121f6ccba695" x1="0" y1="119.705" x2="301.033" y2="119.705" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#167260" /><stop offset="1" stop-color="#1faa8f" /></linearGradient></defs><path d="m238.11,21.329l19.32,31.024-132.276.119c-10.482.021-20.015,5.365-25.502,14.296l-24.749,40.286c-2.307,3.755-2.399,8.292-.249,12.138,2.151,3.846,6.065,5.69,10.518,5.691h100.006l-19.188,30.493c-8.244,13.305-22.509,21.82-38.208,21.852H33.638c-1.712.02-3.295,1.467-4.195,2.923L0,227.801l.014-78.967c.003-17.703,4.937-35.012,14.268-50.057L62.32,21.323C70.577,8.009,84.86.052,100.526.04l49.68-.04,49.693.04c15.666.012,29.948,7.968,38.21,21.289ZM62.752,218.039c8.256,13.382,22.573,21.372,38.297,21.372h99.561c15.709,0,30.019-7.978,38.277-21.34l24.09-38.973,23.726-38.146c9.375-15.073,14.33-32.423,14.33-50.173V11.699l-29.562,47.35c-.241.386-.531.733-.857,1.033-.918,1.404-2.487,2.262-4.18,2.263l-141.266.127c-6.982.014-13.338,3.577-16.996,9.531l-24.749,40.286c-.349.568-.4,1.057-.156,1.494.311.556,1.006.889,1.86.889h130.718c4.412,0,8.453,2.342,10.547,6.111,2.083,3.75,1.949,8.201-.358,11.908l-24.824,39.883c-5.514,8.859-15.035,14.147-25.47,14.148h-.01l-50.265-.018-76.787.901c.813,6.327,2.964,12.429,6.327,17.879l7.747,12.555Z" style="fill:url(#uuid-8788d676-c3d5-4b27-b6ab-121f6ccba695); stroke-width:0px;" /></svg>
</a>

Alt attributes for images

Alt attributes are important in different scenarios. You can use them for actively optimizing you site for the Google Image search. You can also use them to help any visual impaired users of your website, to be able to understand what is in your pictures will help from a screen-reader.

All you have to do is to set an alt attribute with a description of what is actually in your image:

<img src="http://test.frontenddesigner.dk/paulius-dragunas-Nhs0sLAn1Is-unsplash.jpg" alt="Picture of a Lighthouse, by Paulius Dragunas." />

Hreflang & canonical

If you’re not familiar with hreflang and canonical, you can find more info on e.g. Semrush:

I’ve deliberately used hreflang and canonical with errors. They are both pointing to a wrong URL. Both to a relative URL — and to an URL that doesn’t exist. They look like this:

<link rel="alternate" hreflang="da-DK" href="/index-da.html" />
<link rel="canonical" href="/index-.html" />

To fix them, let’s just adjust them to point on existing URLs — and link to an absolute url like this:

<link rel="alternate" hreflang="da-DK" href="http://test.frontenddesigner.dk/index-DA.html" />
<link rel="canonical" href="http://test.frontenddesigner.dk/index-.html" />

Final result

That’s about it. The page now scores 100 / 100!. And that’s just by making sure that:

  • The page is available for indexing

  • The page has a title and description

  • Links have descriptive texts

  • Images have alt attributes

  • Hreflang and canonical (if used) point to absolute URLs

I’ve uploaded an “index2.html” file with these simple adjustments: http://test.frontenddesigner.dk/index2.html

Lighthouse SEO report with 100/100 score.

That’s it for today. Next week I’ll be looking into the “Best practices” part of the Lighthouse report.

If you’re interested in learning more about a specific subject or want me to dig deeper into any part of what I’ve already written about — please don’t hesitate to reach out. You can send me an email at [email protected] — I’ll get back to you and let you know when I’ll take a look at what you’d like to read more about.