Build Issues For Sites in Subdirectories
Your Forestry site is considered to be in a subdirectory if the repo you imported to Forestry contains all of the information pertinent to your static site generator inside of a subdirectory. Depending on the static site generator being used, Forestry may have asked you to enter this subdirectory on import so that it can locate the configuration file for the SSG.
If you’re experiencing problems previewing or deploying in Forestry, and your site is in a subdirectory, you may need to make some updates to your build configuration. This is particularly true if, in order to build the site locally, you navigate to this subdirectory before running your build commands.
Diagnosing Build Errors
If your build log complains of a missing configuration file, or if your preview build succeeds but Forestry can’t open your preview, adjusting your build config will likely solve the problem. Additionally, if the build log declares that you are missing a Gemfile, and you’ve ensured that your project contains a Gemfile, adding the subdirectory info to your build config should resolve the issue.
Including Subdirectory in Preview
To provide subdirectory info to your build config, you will need to do the following:
- Prepend your subdirectory to the output directory. This will give Forestry a complete path from the root of your repo files to the location of the generated website. Note that there should be no need to modify the build command itself.
- Open the advanced configuration for your preview environment and set the Working Directory to the value of your Mount Path, with your subdirectory appended to the end of it.
View the build commands documentation for more information on how to update your build configuration.
Let’s say you have a Hugo site in the subdirectory
site/, and you’re using the default Hugo build image.
- Assuming your build command builds the site to
public/, your Output Directory should be set to
- Assuming you’re using the default Mount Path of
/srv, your Working Directory should be set to
Your build settings would then look something like this:
build: preview_docker_image: forestryio/hugo:latest preview_command: hugo -E -F -D -b $DEPLOY_URL -d public preview_output_directory: "site/public" mount_path: "/srv" working_dir: "/srv/site"
Caught a mistake or want to contribute to the docs? Edit this page on Github!