Only one site is supported on these platforms. You cannot have separate sites for separate branches.
The only way you might do this without some sort of cache/artifact retrieval (as you mentioned is another option in your question) is to build all your branches at once when publishing your Pages site.
How exactly you do that depends on a lot of factors, including what tool(s) you're using to build your site and if they are context-dependent -- but it might look something like this in GitLab
pages:
# fetch the whole repo
# this logic can change if you're on a detached head, like an MR
# so we account for that here
before_script: |
if [[ -n "$CI_COMMIT_BRANCH" ]]; then # branch pipelines
git remote set-url origin "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
git fetch origin
git checkout $CI_COMMIT_BRANCH
fi
if [[ -n "$CI_MERGE_REQUEST_IID" ]]; then # MR pipelines
git remote set-url origin "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_MERGE_REQUEST_SOURCE_PROJECT_PATH}.git"
git fetch origin
fi
script: |
mkdir public
branches=()
# ref: https://stackoverflow.com/a/3847586/5747944
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)"
for branch in "${branches[@]}"; do
git checkout "$branch"
# build each branch and output to public directory
# YOU implement this
make build "$branch" -o "public/${branch}"
done
artifacts:
paths:
- public
environment: # ensure outdated jobs are skipped
name: pages # https://docs.gitlab.com/ee/ci/environments/deployment_safety.html#skip-outdated-deployment-jobs