Problem with Gitlab

Hello there, I have a little problem with my Hugo website. I am posting this on Gitlab Pages. When I run locally, the index page is working just fine. When it lands on gitlab pages, no matter what I have in index.html it doesn’t show the contents at all as it can be seen on my website.

Here is the code for the index.html, which displays a page with blog posts that aren’t pages. On localhost it just works.

{{ define "main" }}
<div class="content">
    <main class="posts">
        {{- if .Content }}
            <div class="content">{{ .Content }}</div>
        {{- end }}
        {{- range .Data.Pages.GroupByDate "2006" }}
            {{- if not (eq .Key "0001") }}
                <div class="posts-group">
                    <div class="post-year">{{ .Key }}</div>

                    <ul class="posts-list">
                        {{- range .Pages }}
                            <li class="post-item">
                                <a href="{{.Permalink}}">
                                    <span class="post-title">{{.Title}}</span>
                                    <span class="post-day">{{ if .Site.Params.dateformShort }}{{ .Date.Format .Site.Params.dateformShort }}{{ else }}{{ .Date.Format "Jan 02"}}{{ end }}</span>
                                </a>
                            </li>
                        {{- end }}
                    </ul>
                </div>
            {{- end }}
        {{- end }}
    </main>
</div>
{{ end }}

I can’t find the problem why the index page doesn’t work correctly after uploading it to gitlab.

There must be some difference in the command arguments you’re passing when running hugo server vs when you run your hugo command to build/push to GitLab Pages. Perhaps you’re building drafts/future pages locally, but not in your build script?

This is the Gitlab build file:

# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
image: registry.gitlab.com/pages/hugo:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

test:
  script:
  - hugo
  except:
  - master

pages:
  script:
  - hugo
  artifacts:
    paths:
    - public
  only:
  - master

Locally I just run hugo server.

Hmm. Something else going on then. Share your code and we can better help you.

Here you go, made the project public.

Cloned your repo. Looks fine locally for me as well. (i’m running Hugo version 0.55.0)

My guess is it’s still something gitlab-related. Maybe others with more knowledge in that area can help you

I have recently set up a couple of sites on GitLab. Have you checked that the settings is correct such as this:

and this:

The baseURL can be a bit tricky also.

I have tried with:

baseURL= “”

and

baseURL = “https://fitnessrebels.gitlab.io

both works, but I suspect that you don’t get a useful sitemap with the first one.

Sometimes you also have to run the CI Pipeline manualy the first time…

You can check my working repo here: https://gitlab.com/fitnessrebels/

Great! You seem to have made it work.

I tried changing the baseurl but the index still isn’t working like it should.
I don’t have the list of blog posts, just a blank page with the header and footer.

This is how it looks locally: