diff options
Diffstat (limited to 'doc/user/project/pages/public_folder.md')
-rw-r--r-- | doc/user/project/pages/public_folder.md | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/doc/user/project/pages/public_folder.md b/doc/user/project/pages/public_folder.md index 751db136e34..6ee8ea17aee 100644 --- a/doc/user/project/pages/public_folder.md +++ b/doc/user/project/pages/public_folder.md @@ -1,12 +1,12 @@ --- description: 'Learn how to configure the build output folder for the most common static site generators' -stage: Create -group: Editor +stage: Plan +group: Knowledge info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments --- -# Configure the public files folder **(FREE)** +# GitLab Pages public folder **(FREE)** All the files that should be accessible by the browser must be in a root-level folder called `public`. @@ -91,14 +91,37 @@ NOTE: GitLab Pages supports only static sites. For Next.js, you can use Next's [Static HTML export functionality](https://nextjs.org/docs/advanced-features/static-html-export). -Use the `-o public` flag after `next export` as the build command, for -example: +With the release of [Next.js 13](https://nextjs.org/blog/next-13) a lot has changed on how Next.js works. +It is recommended to use the following `next.config.js` so all static assets can be exported properly: -```shell -next export -o public +```javascript +/** @type {import('next').NextConfig} */ +const nextConfig = { + reactStrictMode: true, + images: { + unoptimized: true, + }, + assetPrefix: "https://example.gitlab.io/namespace-here/my-gitlab-project/" +} + +module.exports = nextConfig +``` + +An example `.gitlab-ci.yml` can be as minimal as: + +```yaml +pages: + before_script: + - npm install + script: + - npm run build + - mv out/* public + artifacts: + paths: + - public ``` -### Nuxt.js +## Nuxt.js NOTE: GitLab Pages supports only static sites. @@ -146,7 +169,7 @@ module.exports = { ## Should you commit the `public` folder? Not necessarily. However, when the GitLab Pages deploy pipeline runs, it looks -for an [artifact](../../../ci/pipelines/job_artifacts.md) of that name. +for an [artifact](../../../ci/jobs/job_artifacts.md) of that name. If you set up a job that creates the `public` folder before deploy, such as by running `npm run build`, committing the folder isn't required. |