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.
Job log
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
.gitlab-ci.yml
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.
Related guides
GitLab CI "Artifact is too large" / Upload RejectedFix GitLab CI "too large archive" / "413 Request Entity Too Large" artifact uploads - exceeding the max artif…
GitLab CI "dependencies" Job Not Found / Wrong StageFix GitLab CI dependencies errors - listing a job that is not defined, is in a later stage, or produces no ar…
GitLab CI "Cleaning up project directory ... Job failed: exit code 1"Fix GitLab CI "ERROR: Job failed: exit code 1" - a script command returned non-zero. The cleanup line is norm…