How do I deploy a website using a separate CSS stylesheet?
09:09 18 Aug 2026

I want to write a website in HTML using a separate stylesheet in CSS. When I open the index.html directly from my computer everything looks right, but when I commit + push it to GitLab and open my URL, that I'm hosting through GitLab, all of the formatting from the style.css document doesn't show up. So I think somehow the problem is with deploying the website or how the changes are committed?

The beginning of my index.html document looks like this




    
          
    

Linking to my stylesheet in line 7. The linking works when I open it locally but not when deployed to my URL.

My website is hosted through GitLab and I've managed to edit the index.html and commit + push and get the results I was expecting.

I got help to set up the static site hosted through gitlab, so that I can commit and push changes later on and update it myself, so I'm unsure how this was done, but I've read a tutorial on how to do this afterwards and think the process was something like this.

The .gitlab-ci.yml files looks like this

stages:
  - pages

pages:  
  stage: pages
  script:
     - mkdir public
     - cp -r ./*.* ./public/
  artifacts:
    name: $CI_COMMIT_REF_SLUG
    paths:
      - public

Which seems very similar to the tutorial, and I've read that $CI_COMMIT_REF_SLUG is an environment variable that helps make branch names that are suitable in urls.

The other difference is that it does not have this

only:
    - main

Could that be the problem?

html css deployment gitlab