[SOLVED] Deploy to Gitlab

I managed to deploy my blog to Gitlab following the fantastic documents. It went easy and quick. The only thing (not really a problem) I want to deploy my Hugo blog to Gitlab and access it under my (“https://username.gitlab.io”) ?
As I followed the instructions, my blog is available under (“https://username.gitlab.io/projectName”).

Thanks in advance for your helps
and thanks for the polished and organized new docs. It is super easy to follow.

The instructions on the docs regarding Gitlab deployment only cover publishing on a subdirectory (CC @rdwatters )

That may be OK for someone who manages multiple projects with custom domains in his Gitlab repo

But for a user who doesn’t want to use a custom domain on Gitlab Pages the docs instructions will make a Hugo site’s internal links inaccessible because Hugo does not like subdirectories for its root folder.

To deploy with your username @reza you need to do the following in your project’s settings:

Under your username, john, you created a project called john.gitlab.io. Your project URL will be https://gitlab.com/john/john.gitlab.io. Once you enable GitLab Pages for your project, your website will be published under https://john.gitlab.io.


@alexandros Full disclosure: my gitlab experience is next to zero. If you want to submit a PR for corrections/improvements, I would be happy to review it.

Thanks for your reply. I tried the methode you described here but with no luck.
the steps i took:

  1. I deleted the first project(repository) in gitlab
  2. Created another project in gitlab with the name that I wanted to be the url in my case,
    elkraft.gitlab.io” (https://gitlab.com/elkraft/elkraft.gitlab.io)
  3. made a new site using hugo and put the new link in config “https://elkraft.gitlab.io/
  4. copied the .gitlab-ci.yml file in root

and followed the rest of instructions as documents. After gitlab build the site I tried to open the link but nothing.
I tried one more time whole process and this time gitlab did not build the site for some reason.

I deleted the project and I will try to push it to project name subdomain again.

My knowledge of git are very limited. I am trying to learn.
guids, helps are appreciated. Love this community.

Thanks again

The steps you followed are the proper ones to set this up.

My guess is that something is wrong in your local configuration.

How does your config file look like under your local Hugo project directory /.git/config ?

Its contents should be like this

	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[branch "master"]
[remote "origin"]
	url = https://gitlab.com/elkraft/elkraft.gitlab.io.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
[branch "master"]
	remote = origin
	merge = refs/heads/master

Also have you included a .gitlab-ci.yml for Gitlab Pages in the root of your Hugo project, so that the Gitlab Pages runner can build your site?
This file’s contents should be like this:

image: publysher/hugo

  - hugo
    - public
  - master

If you have the above in your local Hugo project and you have set up your Gitlab project settings as you wrote in your previous reply and still you cannot get this to work then ask for help at the Gitlab Forums.

If you’re trying to access your Gitlab repository with SSH it doesn’t work. There a lot of topics at the Gitlab forums about this issue and workarounds but I haven’t bothered. HTTPS works out of the box.

1 Like

Thank You so much for your help. It worked perfectly. The problem was in my .git/config.
I only copy pasted your script and now my blog is up and running.
Thanks again onedrawingperday

You’re welcome.

Just one question more:
How to mark this topic as solved?

I just did it for you.