GitLab Pages Job Fails - "public" Folder Missing or Wrong Stage
GitLab Pages is published by a specially-named pages job that must produce a public/ directory as an artifact. If that contract is not met, the deploy step fails.
What this error means
The build script succeeds but Pages does not publish: the job is not recognized as Pages, the pages:deploy step errors, or the site 404s because public/ was empty or never uploaded.
Uploading artifacts...
WARNING: public: no matching files. Ensure that the artifact path is relative to the working directory
ERROR: No files to uploadCommon causes
Output not placed in public/
Pages serves the contents of the public/ artifact. A generator that writes to dist/ or build/ produces no Pages content unless you move or configure the output to public/.
Job not named pages or missing artifact
GitLab triggers the Pages deploy only for a job named pages (or one with a pages: config) that declares artifacts:paths: [public].
How to fix it
Emit public/ from the pages job
pages:
stage: deploy
script:
- npm run build
- mv dist public
artifacts:
paths:
- publicCheck the pages:deploy result
- Confirm the
pagesjob uploaded a non-emptypublic/artifact. - Open the follow-on
pages:deploystep in the pipeline - its log states why a deploy was rejected. - Verify your Pages base path matches how the static site references assets.
How to prevent it
- Always output the site to
public/in thepagesjob. - Declare
artifacts:paths: [public]so the deploy has content. - Build asset URLs relative to the configured Pages base path.