Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO - description audit #3227

Merged
merged 7 commits into from
Sep 12, 2017
Merged

Conversation

kdzwinel
Copy link
Collaborator

@kdzwinel kdzwinel commented Sep 1, 2017

Closes #3175

@@ -7,6 +7,15 @@

module.exports = {
extends: 'lighthouse:default',
passes: [{
passName: 'seoPass',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patrick says you can just passName: 'defaultPass' and get this gather merged into that one.

so no need for an extra pass

*/
static audit(artifacts) {
return {
rawValue: (artifacts.Description !== null && artifacts.Description.length > 0)
Copy link
Collaborator Author

@kdzwinel kdzwinel Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should we also .trim() it?
  2. Should we include an additional text saying either "Description tag wasn't found" or "Description is empty"?
  3. BTW I've spotted that returning a numeric value here causes test to fail but green tick to be shown next to the test:

screen shot 2017-09-01 at 21 21 45

Is this a bug?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. trim sgtm
  2. debugString for those cases would be nice
  3. yes this seems like a bug :) there's some magic that happens if the rawValue is a number to auto-populate the score but even if that's producing something weird the UI should still be consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for help! Regarding no.3 - should I create an issue for it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistency does look like a bug. In the meantime, should be able to set scoringMode: Audit.SCORING_MODES.NUMERIC in the meta information (otherwise everything other than 100 is interpreted as failing)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brendankenny thanks! For this audit rawValue is a boolean so we are fine, but I'll keep your advice in mind for the next ones.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the meta description exists but is invalid, I'd also recommend including the markup in the debugString. For example:

Description text is empty: `<meta name="description" content="     ">`

It'll be helpful for developers to know where to look to fix the issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rviscomi I think that's a good idea, but I wonder if it won't be confusing to show <meta name="description" content=" "> while the actual tag on page may look totally different (e.g. <META YADA="yada" CONTENT=" " name="description" />)?

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! very clean 👍

@@ -7,6 +7,15 @@

module.exports = {
extends: 'lighthouse:default',
passes: [{
passName: 'seoPass',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you set passName to 'defaultPass' then the gatherer should just be added to the list to run, if not it's a bug and I can look into it :)

helpText: 'Meta descriptions may be included in search results to concisely summarize ' +
'page content. Read more in the ' +
'[Search Console Help page](https://support.google.com/webmasters/answer/35624?hl=en#1).',
requiredArtifacts: ['Description']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description is rather generic, what about MetaDescription or start namespacing with SEODescription if there are going to be many more seo specific ones?

…artifact to MetaArtifact (and update gatherer file name accordingly)
@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Sep 1, 2017

@paulirish @patrickhulce thank you for your comments!

  1. defaultPass - it works! However, it looks like my gatherer is now painfully slow for some reason:
  status Retrieving: WebSQL +2ms
  status Retrieving: MetaDescription +500ms

Interestingly, the problem goes away if it's not running last:

  status Retrieving: MetaDescription +3ms
  status Retrieving: WebSQL +3ms

🤔
[EDIT] It seems to me that 'MetaDescription' taking 500ms has something to do with WebSQL having a 500ms timeout -

  1. I've renamed Description artefact to MetaDescription and updated gatherer's name accordingly.

  2. I'll appreciate someone helping me with these questions: SEO - description audit #3227 (comment)

@patrickhulce
Copy link
Collaborator

It seems to me that 'MetaDescription' taking 500ms has something to do with WebSQL having a 500ms timeout

Yeah the debug timestamps are confusing to read, the x ms is reporting to you how many milliseconds have passed since the previous statement, since we print the name of the gatherer before we call it, the time for a gatherer is actually printed on the next line

@ali999abas
Copy link

Good job

@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Sep 2, 2017

x ms is reporting to you how many milliseconds have passed since the previous statement

thanks for explanation, it makes sense (although I'll have to agree that it's not very intuitive)

I've added description trimming and debugStrings. PTAL

*/
static get meta() {
return {
category: 'Content Best Practices',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta question for the LH team. category here is referring to the title of the audit group, not to be confused with the top-level audit category, SEO, defined in the config file?

https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/seo.js#L25-L27

Copy link
Collaborator

@patrickhulce patrickhulce Sep 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rviscomi yeah the field here has an ambiguous name and is not used anywhere anymore 😆

I'm in favor of removing entirely now that we have real categories that control quite a bit of report building (just as cleanup work by the LH team in other PRs, it's a mandatory field currently).

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

if (artifacts.MetaDescription === null) {
return {
rawValue: false,
debugString: 'Description meta tag is missing.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that you've brought it up in the other issue, I think I might have a slight preference to put these in the displayValue and keep debugString for errors like the gatherer failing (which is handled automatically)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that you've brought it up in the other issue, I think I might have a slight preference to put these in the displayValue and keep debugString for errors like the gatherer failing (which is handled automatically)

agree about confusion between user vs system errors in debugString, but don't we still want the red string for failure here? (We still use the guidance "Optional error string for helping the user figure out why they failed here." in our docs)

Copy link
Collaborator Author

@kdzwinel kdzwinel Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO debugString is more readable and, as @brendankenny mentioned, in this case it matches the description from the docs:

/**
* Optional error string for helping the user figure out why they failed here.
* @type {(string|undefined)}
*/
AuditResult.prototype.debugString;

@patrickhulce WDYT? Can we keep the debugString here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sgtm, I'm sort of off the reservation when it comes to my hopes for debugString anyway :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put the title and debugString in the order you'd see them in the report:

Document does not have a meta description

Description meta tag is missing

Given that the debugString duplicates so much, i think we should exclude it.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gatherer unit tests are often inadequate as they tend to just be a test of how accurate the test mock is. We should set up integration tests for the incoming SEO audits so we can assert that the full gather-to-audit process is working.

It could be added to an existing test suite, but setting up a new one that uses the SEO config may be the best first step (unless anyone feels otherwise).

I think it's ok to not handle it in this PR so it stays nicely focused, but we should get one going ASAP


describe('SEO: description audit', () => {
it('fails when HTML does not contain a description meta tag', () => {
return assert.equal(Audit.audit({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to assert that the audit is also returning a debugString (or a displayValue, depending on how the comment above shakes out :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do 👍

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just last two nits and I think I'm good

@@ -28,7 +37,8 @@ module.exports = {
description: 'These ensure your app is able to be understood by search engine crawlers.',
audits: [
{id: 'meta-viewport', weight: 1, group: 'seo-mobile'},
{id: 'document-title', weight: 1, group: 'seo-content'}
{id: 'document-title', weight: 1, group: 'seo-content'},
{id: 'meta-description', weight: 1, group: 'seo-content'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: go for the trailing comma here so future diffs will be cleaner

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw trailing comma being used here and there, but since there is no 100% consistency, I left it out. The cleaner diffs argument SGTM, maybe we should make eslint to check for that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK there wasn't any effort to do trailing commas other than occasionally sneaking them in as we touched code but huge +1 to turning on the eslint rule :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened an issue for it: #3304 👍

MetaDescription: null
});
assert.equal(auditResult.rawValue, false);
assert.ok(auditResult.debugString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would probably be (slightly) better to check which string is getting returned as the debugString since there's two different cases (could go for an exact string match or a debugString.includes() on 'empty' and 'missing'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to a quick includes check

if (artifacts.MetaDescription === null) {
return {
rawValue: false,
debugString: 'Description meta tag is missing.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put the title and debugString in the order you'd see them in the report:

Document does not have a meta description

Description meta tag is missing

Given that the debugString duplicates so much, i think we should exclude it.

if (artifacts.MetaDescription.trim().length === 0) {
return {
rawValue: false,
debugString: 'Description text is empty.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Seems okay to keep this, as it's an unexpected case that'd otherwise be hard to debug.

@kdzwinel
Copy link
Collaborator Author

kdzwinel commented Sep 9, 2017

I removed the 'tag missing' debugString, added the missing trailing comma and, updated tests to check debugString with includes (there is only one debugString now, but IMO it still makes sense to have includes).

PTAL

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woohoo! Let's land

@brendankenny brendankenny merged commit c6ed5b5 into GoogleChrome:master Sep 12, 2017
@brendankenny brendankenny mentioned this pull request May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants