When creating a new GitLab project, GitLab allows you to start with a template instead of a blank project.
One of the templates is is the Pages/Plain HTML

This template uses a minimal CI workflow that does nothing.
All files in the public directory of the project will end up in the root of the web page.

For your use case, you just need to put your web page files (like index.html) into the public directory and run the CI pipeline once.
If your repository is on gitlab.com, one of the public runners can be used with your project without setting up any custom runners.

For more details, see the Create a GitLab Pages website from a project template documentation.

To view the logs of a GitLab Pipeline/Jobs go to Build -> Jobs
and click the latest Job with a red X symbol and Failed text.

The problem in your CI script is:

$ cp index.html public/
cp: cannot create regular file 'public/': Not a directory

Answer from Peter on Stack Overflow
🌐
GitLab
gitlab.com › gitlab pages examples › plain-html
GitLab Pages examples / plain-html · GitLab
Example plain HTML site using GitLab Pages: https://pages.gitlab.io/plain-html
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › deploy and release your application › gitlab pages
GitLab Pages | GitLab Docs
To publish a website with Pages, use any static site generator like Gatsby, Jekyll, Hugo, Middleman, Harp, Hexo, or Brunch. Pages also supports websites written directly in plain HTML, CSS, JavaScript, and Wasm. Dynamic server-side processing (like .php and .asp) is not supported.
Discussions

git - Can I render HTML on GitLab? - Stack Overflow
GitLab Pages is a feature that allows you to publish static websites directly from a repository in GitLab. More on stackoverflow.com
🌐 stackoverflow.com
git tag - Serve static html pages with Gitlab Pages for each tagged version of a project - Stack Overflow
I have a code project hosted on a custom gitlab instance. This project is part of a subgroup. We'd like to host static html content, generated by doxygen and similar tools, using Gitlab Pages. Triv... More on stackoverflow.com
🌐 stackoverflow.com
git - Host static website with GitLab pages - Stack Overflow
I did some research but there aren't ... GitLab pages. How could I change this file to make it work? Other info that might be useful: GitLab username: gpecchio GitLab project name: BeCall GitLab project url: https://gitlab.com/gpecchio/BeCall ... Save this answer. ... Show activity on this post. Is your website created in html or are you using a static generator ... More on stackoverflow.com
🌐 stackoverflow.com
How can I view artifacts ( html page, .txt fiile etc., ) in GitLab?
There’s no way to view it, you gotta download it More on reddit.com
🌐 r/gitlab
6
2
August 5, 2024
🌐
Gitlab
how-to-stuff.gitlab.io › gitlab-pages-how-to
How To: GitLab Pages - HTML Hosted Page
Save the HTML outline and put it in your localfolder/public directory. If you decide you want CSS - make sure to put all contents in your public directory. You can also use a static site generator that utilizes a prebuilt framework in the language of your choice.
🌐
YouTube
youtube.com › watch
HOW TO Build and Host a Static Web Page with GitLab Pages - YouTube
GitLab Pages is an easy way to build and host a static website. In this walkthrough, I'll show you how you can create a static HTML webpage that is built and...
Published: November 3, 2021
🌐
Medium
medium.com › turpialdev › how-to-host-an-html-page-in-gitlab-pages-47bbfbdeb4d1
How to host an HTML page in GitLab Pages | by Turpial Development | Turpial Dev | Medium
November 27, 2018 - GitLab Pages gives you the opportunity to create web pages using several static site generators. Some of the best known are Jekyll, Pelican, Hugo, etc. In this article, we will focus on html pages and we will see step by step how to host our ...
🌐
300feetout
300feetout.com › blog › hosting-static-site-gitlab-pages
hosting a static HTML site on gitlab pages
Gitlab Pages can host everything from plain old HTML to your favorite SSG (Static Site Generator). We’ve used it to host static HTML, Gatsby, and NextJS sites.
Find elsewhere
🌐
YouTube
youtube.com › watch
Homelab Series - Creating a Static HTML site in Gitlab Pages Self Hosted - YouTube
Welcome to my Homelab Series! Here we will go through how to a create a static HTML site in Gitlab Pages Self Hosted!For Business Inquiries you can email me ...
Published: August 27, 2023
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › deploy and release your application › gitlab pages › create deployment for static site
Create a GitLab Pages deployment for a static site | GitLab Docs
Generates static sites or a client-rendered single-page application (SPA), like Eleventy, Astro, or Jekyll. Contains a framework configured for static output, such as Next.js, Nuxt, or SvelteKit. GitLab Pages must be enabled for the project.
Top answer
1 of 3
17

First of all, Git and products like GitLab and GitHub are different things. Git doesn't ever render anything; it's a version control system. It doesn't have a web interface.

Secondly, GitLab's core product isn't supposed to render anything. It's not a web host, it's a tool for hosting, sharing, and managing Git repositories. However you might want to try GitLab Pages:

GitLab Pages is a feature that allows you to publish static websites directly from a repository in GitLab.

You can use it either for personal or business websites, such as portfolios, documentation, manifestos, and business presentations. You can also attribute any license to your content.

Pages is available for free for all GitLab.com users as well as for self-managed instances (GitLab Core, Starter, Premium, and Ultimate).

GitLab Pages will publish content from the public/ directory of your repository, so you should move your files there. You will also need a .gitlab-ci.yml file in the root of your repository containing something like

image: alpine:latest

pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
  artifacts:
    paths:
    - public
  only:
  - master

(taken from the sample repository). Add that file, then commit and push. After deployment is complete, your site should be available at https://youruser.gitlab.io/yourproject.

Note that GitHub has a similar product (that works differently).

Finally,

I looked at other projects' repositories, such as pandas, sphinx. They only have .rts files in the repository, and not HTML files. I guess they generate HTML for their websites but don't upload to Git.

it's very likely that the reStructured Text files are the only source that exists, and that HTML is generated from them automatically. Sphinx this format by default. If you're interested in working from another format like Markdown or reStructured Text you may want to explore GitLab Pages' support for static site generators.

2 of 3
9

Another solution:

At the root of your repo, add a file called .gitlab-ci.yml containing the following lines:

pages:
 script:
 - mkdir .public
 - cp -r * .public
 - mv .public public
 artifacts:
    paths:
    - public

Your file should then be available at

 https://your-username.gitlab.io/project-name/filename.html

See this post for details: Gitlab: host and render HTML files

🌐
Stack Overflow
stackoverflow.com › questions › 73868024 › serve-static-html-pages-with-gitlab-pages-for-each-tagged-version-of-a-project
git tag - Serve static html pages with Gitlab Pages for each tagged version of a project - Stack Overflow
Copypages: stage: build image: alpine:3.18 cache: key: gitlab-pages paths: [public] before_script: # default available 'tree' app in alpine image does not work as intended - apk add tree - mkdir -p public/$CI_COMMIT_REF_SLUG && ls public - rm -rf public/$CI_COMMIT_REF_SLUG || true # remove last version of current tag script: - ./generate-my-html.sh --output build-docs || true # insert here your code that generates documentation - mv --verbose build-docs public/$CI_COMMIT_REF_SLUG - cd public - tree -d -H '.' -L 1 --noreport --charset utf-8 -T "Releases" -o index.html # generate a root HTML lis
🌐
Medium
medium.com › @vinoji2005 › day-12-using-gitlab-pages-for-static-website-deployment-42e290d83ecd
🔨 Day 12: Using GitLab Pages for Static Website Deployment | by Vinoth Subbiah | Medium
October 1, 2024 - GitLab Pages is a static site hosting service that allows you to deploy HTML, CSS, and JavaScript files from a GitLab repository.
🌐
Publii
getpublii.com › docs › host-static-website-gitlab-pages.html
How to create a static website using GitLab Pages (Full Guide)
August 8, 2024 - Next, click on the Create project button: The project is now created and you'll be on the project's home screen. As Gitlab uses pipelines to publish static websites we'll have to create a special file to take care of this.
🌐
Osamathe
blog.osamathe.dev › blog › deploy-gitlab-pages
Deploy a Static Website with GitLab Pages - Osama's Tech Blog
January 28, 2023 - First we run npm install to get all the dependencies, then we run npm run build to generate the dist folder. That last echo command is used to create a file in the dist directory that tells GitLab that all URLs should return the index.html file. Meaning <YOUR GITLAB PAGE BASE URL>/ and <YOUR GITLAB PAGE BASE URL>/something/ should both return the index.html.
🌐
PRACE
repository.prace-ri.eu › help
Index · Pages · Project · User · Help · GitLab
With GitLab Pages, you can publish static websites directly from a repository in GitLab. Use for any personal or business website. Use any Static Site Generator (SSG) or plain HTML.
🌐
Mindful Chase
mindfulchase.com › home › deep dives › master gitlab workflows › gitlab pages: deploying static websites and documentation
GitLab Pages: Deploying Static Websites and Documentation - Mindful Chase
December 1, 2024 - GitLab Pages is a built-in service that lets you publish static websites from your GitLab repository. It supports any static site generator, such as Jekyll, Hugo, or Gatsby, as well as plain HTML, CSS, and JavaScript files.
🌐
Nira
nira.com › home › the ultimate manual to gitlab pages
The Ultimate Manual To GitLab Pages - Nira
May 3, 2022 - To be able to publish a website with GitLab Pages, you’ll need a Static Site Generator (e.g., Jekyll, Middleman, Gatsby, Hugo, Brunch, or Harp). You can also publish websites written directly in plain HTML, JavaScript, and CSS.
🌐
Medium
medium.com › @bnalaska96 › gitlab-project-intro-static-website-36c32b2969a1
GITLAB Project Intro — Static website | by Bjorn Nielsen | Medium
April 16, 2022 - On GitLab home page choose ‘Create a project’ -> ‘Create blank project’ ... <!DOCTYPE html> <html> <body> <h1>Welcome</h1> <a href="https://www.levelupintech.com/">You can do this too, LEVEL UP!</a> </body> </html>