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

img source base path for GH pages breaks build #917

Open
Rikidink opened this issue May 11, 2024 · 1 comment
Open

img source base path for GH pages breaks build #917

Rikidink opened this issue May 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Rikidink
Copy link

Describe the bug
I followed the steps to host statically along with the steps to host on github pages. The yarn build step would always fail due to changing the img source path in components/Image.tsx to the provided one for GH pages deployment.

To Reproduce
Follow section on "Static hosting services" in README.
Follow steps in faq/github-pages-deployment.md.
Run yarn build.

System Info:

  • OS: Windows 11
  • Node version: 18.17.0
  • Npm version: 9.6.7

Additional context
I got it working by changing the img src path to an absolute path where {username} is my Github username and {repo-name} is my repo name:

import NextImage, { ImageProps } from 'next/image'

const Image = ({ src, ...rest }: ImageProps) => (
  <NextImage src={`https://{username}.github.io/{repo-name}${src}`} {...rest} />
)

export default Image
@Rikidink Rikidink added the bug Something isn't working label May 11, 2024
@timlrx
Copy link
Owner

timlrx commented Jun 2, 2024

Here's the recommended change required to deploy on github pages: https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/faq/github-pages-deployment.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants