question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Mobile-Friendly Test Failing for Gatsby with no CSS via styled-components

See original GitHub issue

I am using Gatsby + styled-components for my new VSCode course site. Everything looks fine on Desktop/Mobile but Google Mobile-Friendly test is failing miserably. Which is costing me SEO and more.

I am out of options, searched about it and didn’t find anything. I think I added the webfontloader plugin since then I started having this issue. But not sure. I’ve since removed it. Any help would be appreciated.

image

This is what I see on Google’s Mobile-friendly test.

image

Steps to reproduce

Here’s the HTML in case you need it to test. I opened this HTML up and yes, there is actually no CSS to be found. Click this raw file, it’s huge so not adding it here.

Expected result

CSS should be loaded by Google Mobile-Friendly test it is not at the moment. I am out of options so creating this issue to get some pointers on what to do. This is what the site should look like.

image

Actual result

CSS is not loaded 😦

image

Even if I try loading this HTML that I got from Google Mobile-friendly test, this is exactly what I see. No CSS.

image

Environment

 System:
    OS: macOS High Sierra 10.13.5
    CPU: x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.11.0 - ~/.asdf/shims/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.asdf/shims/npm
  Browsers:
    Chrome: 70.0.3538.110
    Firefox: 57.0.1
    Safari: 11.1.1
  npmPackages:
    gatsby: ^2.0.44 => 2.0.44
    gatsby-cli: ^2.4.6 => 2.4.6
    gatsby-image: ^2.0.20 => 2.0.20
    gatsby-plugin-google-analytics: ^2.0.7 => 2.0.7
    gatsby-plugin-manifest: ^2.0.8 => 2.0.8
    gatsby-plugin-offline: ^2.0.13 => 2.0.13
    gatsby-plugin-react-helmet: ^3.0.1 => 3.0.1
    gatsby-plugin-sharp: ^2.0.12 => 2.0.12
    gatsby-plugin-sitemap: ^2.0.3 => 2.0.3
    gatsby-plugin-styled-components: ^3.0.1 => 3.0.1
    gatsby-source-filesystem: ^2.0.8 => 2.0.8
    gatsby-transformer-sharp: ^2.1.8 => 2.1.8
  npmGlobalPackages:
    gatsby-cli: 2.4.3

Looking forward, peace! ✌️

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mxstbrcommented, Dec 4, 2018

I’m really not sure—that sounds like an issue with the Gatsby plugin!

0reactions
rohanbhanguicommented, Nov 8, 2021

I wanted to follow this up, because I think its important to understand what is important in the google crawler. It does not matter that the page is styled correctly, but that the content appears and is parsable. With that said a work around would be to allow for a small css file to be crawlable by google (via a robots.txt) + include a small css file that will quickly load at run time and then is overridden by styled component styles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Ways Your Site Might Fail Google's Mobile-Friendly Test
Here are the 5 most common things that cause a seemingly mobile-optimized site to fail Google's Mobile-Friendly Test. 1. Blocking CSS or JS ......
Read more >
Get started with Gatsby and Unit Testing - Daniela Baron
This post will demonstrate how to add unit tests to a Gatsby project using Jest and react-testing-library. Gatsby is a static site generator ......
Read more >
CSS breaks in Mobile Friendly Test - Google Support
The problem is the Google Mobile Friendly Test. Here the page is completely disassembled and many page resources are not loaded.
Read more >
Problems with Emotion (Styled Components) on Gatsby
This is happening because in Emotion 11 the package names have changed. I don't believe gatsby-plugin-emotion is up to date yet, ...
Read more >
The React Handbook - Medium
This book does not try to cover everything under the sun related to React, ... example used in React by Styled Components, to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found