Gatsby: html.js not being read on gatsby theme

Created on 31 Oct 2019  路  3Comments  路  Source: gatsbyjs/gatsby

Description

I have a custom html.js in the root of the src directory for a theme I have created.
However this is not being built in a site that consumes the theme. The html.js file seems to be completely ignored.

Steps to reproduce

  1. Create a starter gatsby theme.
  2. Add in a custom html.js to the theme using the steps found here
  3. Add some custom code to the theme to distinguish it from the default
  4. Add the theme to a gatsby site.
  5. Run the site using develop or build. You will see that customisations are not coming through.

Expected result

The html.js file in the theme should be read and built.

Actual result

The html.js file is ignored in the theme.

Environment

  System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.16.1 - ~/.nvm/versions/node/v10.16.1/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v10.16.1/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 78.0.3904.70
    Safari: 13.0.2
  npmGlobalPackages:
    gatsby-dev-cli: 2.5.7
bug

All 3 comments

Thank you for opening this!

I wouldn't count this as a bug as using html.js is already a workaround solution for people who don't want to use the appropriate APIs. You should use onRenderBody for example instead. Therefore I'd say this is a "nofix" from our site as you are able to achieve your desired behaviors with our APIs.

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Hey @LekoArts the solution of onRenderHTML is the one I went with in the end.
I think it's probably worth mentioning this in the article I linked to in the initial description to clear this up for other developers of themes.

Happy to pick this up if it is not mentioned elsewhere in the documentation?

Sure, go ahead!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  路  3Comments

theduke picture theduke  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

ghost picture ghost  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments