Next.js Discord

Discord Forum

Static deployment over GitHub pages

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
I am trying to deploy the starter static blog example over github pages.

The issue that I am currently facing is,
After the build is deployed, static images fails to load due to the path not matching. Here is the website: https://realchakrawarti.github.io/aham/

# Include the relevant chunks of code in your post
Here is my next.config.js
/**
 * @type {import('next').NextConfig}
 */

const isDevelopement = process.env.NODE_ENV === "development" || false;
const prefixPath = "/aham";

const nextConfig = {
  reactStrictMode: true,
  basePath: isDevelopement ? "" : prefixPath,
  assetPrefix: isDevelopement ? "" : prefixPath,
  output: "export",
  images: {
    unoptimized: true,
  },
};

module.exports = nextConfig;


Here is the link to the repository: https://github.com/realChakrawarti/aham

# Include the logs/errors you are receiving
No errors or relevant warnings during build or running locally

# Explain what you've tried to solve the issue
I have tried using process.env.NODE_ENV to set basePath and assetPrefix.

If the directly prefix aham (repo name) in the browser's URL of the image like this, https://realchakrawarti.github.io/aham/assets/blog/dynamic-routing/cover.jpg it loads fine in the browser.


Help appreciated.

0 Replies