block by shawnbot 3d2ffb5bbb318022b7b31d953c67c216

18F Pages Federalist preview URL fix

How to fix Federalist baseurl problems on 18F guides

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}/.

  1. Place the attached 18f-pages.rb in the _plugins directory at the project root

  2. Replace the {repo} placeholder text in the plugin with the name of your guide, e.g. accessibility or content-guide

  3. Create a pull request for adding this plugin and get it merged

  4. Log in to Federalist and remove the baseurl: /{repo} line from the site’s custom configuration under “Settings”

  5. Wait for the site to rebuild and test out the https://pages.18f.gov/{repo}/ URL to be sure it works in production

  6. Revisit the site’s Federalist settings and make sure that “Allow Anyone To See Previews Of Draft Sites” is checked

  7. 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.

18f-pages.rb