Open alansegar opened 4 years ago
Hi,
The useSiteMetadata.ts
react hooks gets data from gatsby-config.js
. I saw in this link (https://www.gatsbyjs.com/docs/path-prefix/#add-to-gatsby-configjs), it says to add the following code :
module.exports = {
pathPrefix: `/blog`,
}
But, if you remove this following
module.exports = {
siteMetadata: {
title: `Gatsby Typescript blog Starter`,
description: `A simple blog starter using Typescript in front & back side with eslint & prettier.`,
author: {
name: 'Julien CARON',
content: 'I like build some things using Javascript',
},
social: {
github: 'https://github.com/Junscuzzy',
},
},
}
So the hook GraphQL query fails.
You can either add the pathPrefix
afterwards, or remove or update the hook.
I haven't planned any specific support for the pathPrefix
yet.
For applications hosted at something other than the root (/) of their domain, there are instructions at https://www.gatsbyjs.org/docs/path-prefix/ which describe how to set up Gatsby for this.
Have you managed to get that to work with this starter / do you have any plans to add support for it?
After following https://www.gatsbyjs.org/docs/path-prefix/#add-to-gatsby-configjs and https://www.gatsbyjs.org/docs/path-prefix/#add-to-gatsby-configjs, when serving the contents of the
public
folder on a webserver at something other than the root of the domain, I get this error:which seems to indicate it's something to do with
useSiteMetadata.ts
in this starter but I've not yet managed to figure out what changes would be required to get it to work or whether it is actually a bug in Gatsby as suggested in the error message. I've searched online for the error text and can see several issues mentioning it but none seem to be exactly the same as this.I've followed the same process successfully with a different starter which doesn't have any custom hooks so I'm reasonably confident that the process I've followed does work and the error isn't related to that. The only changes I've made to the starter are what I've described here plus the removal of the graphQL dependency as described in https://github.com/Junscuzzy/gatsby-material-typescript-starter/issues/1
To narrow down the cause, I've since temporarily changed src/layout/index.tsx to use a hard-coded
title
rather than getting it fromuseSiteMetadata()
. I also deleteduseSiteMetadata.ts
and with those changes in place, the site works normally with path prefix.