When we migrated all of 18F’s guide repos from the 18F Pages system to Federalist, we introduced a minor issue: Federalist branch previews now have their Jekyll baseurl
set to the guide’s permalink in the Federalist custom configuration, which overrides the command line argument that Federalist provides to preview builds. The fix described below involves a very basic Jekyll plugin that conditionally sets the baseurl
for the guide only if the git branch is 18f-pages
, and leaves branch previews to be built with the correct base URL at https://federalist.18f.gov/preview/18f/{repo}/{branch}/
.
Place the attached 18f-pages.rb
in the _plugins
directory at the project root
Replace the {repo}
placeholder text in the plugin with the name of your guide, e.g. accessibility
or content-guide
Create a pull request for adding this plugin and get it merged
Log in to Federalist and remove the baseurl: /{repo}
line from the site’s custom configuration under “Settings”
Wait for the site to rebuild and test out the https://pages.18f.gov/{repo}/
URL to be sure it works in production
Revisit the site’s Federalist settings and make sure that “Allow Anyone To See Previews Of Draft Sites” is checked
Create a new test branch off of 18f-pages
and push a change to test Federalist preview URLs at:
https://federalist.18f.gov/preview/18f/{repo}/{branch}/
See this pull request for the fix applied to our accessibility guide.