Skip to content

Consider adding an example for how to serve many pages

What Do I Mean?

Very often, your static gitlab pages site has more than just an index.html page, and it would make sense to provide an example on how to arrange your pubic folder to serve everything else.

Looking through the code for gitlab-pages, I notice the following lines:

https://gitlab.com/gitlab-org/gitlab-pages/blob/master/domain.go#L118

case fi.IsDir() && !strings.HasSuffix(r.URL.Path, "/"):
		newURL := *r.URL
		newURL.Path += "/"
		http.Redirect(w, r, newURL.String(), 302)

which suggests the pages daemon expects every html file to be named index.html and to reside inside a dir whose name is the url path. This certainly wasn't obvious to me and caused me much butthurt when trying to figure out why html pages I had were 404-ing.

How

I personally think it would be super helpful if we could document this expected structure somewhere; something like a simple json would do:

{
  "/": "public/index.html",
  "terms-of-service": "public/terms-of-service/index.html",
  "posts": "public/posts/index.html",
  "posts/new": "public/posts/new/index.html",
  "post/1": "public/posts/1/index.html",
  "post/1/edit": "public/posts/1/edit/index.html"
}

And provide an example project showcasing how multiple pages can be served - consider using my existing ember.js based project pages.