Baseurl, url, and other settings when using GitHub Actions?

I am moving from GitHub Pages to building my site with GitHub Actions. There will be a Jekyll site repo just for writing code and posts. I am using, so I do want it to build and show the site functioning using the Forestry preview options.

I will plan to develop locally, use as mentioned above, and also display the website via a custom domain from another GitHub repo (not another branch).

My primary concerns are that I can:

  1. Modify and test code locally
  2. Create posts and preview them in Forestry
  3. Get proper absolute and relative urls in the final Jekyll website

Before I go and kick off this project, my biggest question is whether or not I should be setting up multiple baseurl and url items in the _config.yml file? Are there any other things I might be missing in terms of having the flexibility between moving between local and remote dev repos and a prod repo?


1 Like

pretty sure you only need a baseurl if you are using a project on GH - or are otherwise hosting via a subfolder. If you are using a custom domain you shouldn’t need a baseurl unless you want to host it at or something like that.

When I do stuff with AWS Amplify it uses a subdomain with a weird url - and that is fine, it is not a sub folder like GH does if that is what you are worried about with forestry. I don’t use it so I am not sure what it does but if you are saying it makes a preview site at that is just your site you should be fine.

Personally I stay away from absolute urls except if I want to set a canonical meta tag in the head - then I use an absolute url for that, but everything else is a relative url to the root of the site. From what I have read there is no advantage to using absolute urls, but it does have disadvantages for they type of things you are talking about.

I’m not exactly an expert though!

Thank you for this. So far, I know I can do local development using an empty baseurl since my Jekyll site is at the root folder. I can also debug and test on my local machine using the domain name of without any errors. The bigger concern was building to the separate site, which I will hopefully be doing by end of this week/first thing next week. I’ll update this post as the answer if no problems or report back :slight_smile:

Thanks so much!

1 Like

Hmm there are a lot of pieces to your question.

The thing that stands out is custom domain.

If your idea is to serve on the root of

Then you do want an empty baseurl.

It doesn’t matter whether your repo ends up being on a subpage or the root on GH Pages, because the end result will be on the root. Therefore you should set

baseurl: ''

Even if it ends up being on

As the custom domain lack of subpath.

If it weren’t for that need, I’d say set baseurl in the config. And have that set on Forestry config if needed and for local use so you use subpath throughout.

I don’t know why you need to build to a separate repo. I find building to gh-pages branch works

An advantage is that maybe you have the one repo and it’s GH Pages set up as your staging site. And you tell Google not to crawl it. Then push a bunch of commits or PRs there. And use that as your preview. Without Forestry to handle a preview.

Then use GH Actions to build the site across repos selectively like on a tag made, commit to master, or “ci” in commit message

Having multiple configs is not useful here.

Url field only gets used on a production build with JEKYLL_ENV=production and won’t be used locally unless you specially want to test contents of RSS or sitemap files.

Oh I guess Forestry would probably need that Jekyll env to be development ie not prod, so that the preview mode serves on localhost and not on the prod URL. That way you don’t need another url for Forestry set up

And it is best to keep the same baseurl on all environments to keep things consistent and close to the final result.