forked from 18F/18f.gsa.gov
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create siteurl.rb to try to fix redirect issue
- Loading branch information
1 parent
1b8c732
commit 19ba226
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Jekyll::Hooks.register :site, :after_init do |site| | ||
# Federalist will set the BRANCH environment variable when it's building a | ||
# preview deployment. If the branch is nil (unset) or "main", do nothing. But | ||
# for preview builds, set site.url to nil. If we don't do that, then site.url | ||
# will be used by the jekyll-redirect-from plugin when it rewrites redirects, | ||
# which will link AWAY from the preview site and to the production site, | ||
# making it functionally impossible to preview the redirected page. Further, | ||
# because the production and preview sites have different site.baseurl values, | ||
# the redirect will go to a location that does not exist in production, so | ||
# it'll just cause a 404. | ||
# | ||
# We can avoid all that by just emptying the site.url value on preview builds. | ||
branch = ENV['BRANCH'] | ||
if !(branch.nil? || branch == 'main') | ||
site.config['url'] = nil | ||
end | ||
end |