GSA / data.gov

Main repository for the data.gov service
https://data.gov
Other
633 stars 100 forks source link

Fix relative pathing of 11ty Static Site #4033

Closed btylerburton closed 2 years ago

btylerburton commented 2 years ago

We should be able to supply a process.env.BASEURL to the build that will allow relative links to function correctly. This will remove the 404's from the Federalist build.

How to reproduce

  1. Navigate to the Federalist build https://federalist-2ac784db-2321-4734-8d02-933835d88304.app.cloud.gov/site/gsa/datagov-11ty/
  2. Attempt to click on any relative link: 2.1. https://federalist-2ac784db-2321-4734-8d02-933835d88304.app.cloud.gov/maritime/hydrosurvey-data-archive-for-federal-navigation-projects/ >> gives a 404 2.2. https://federalist-2ac784db-2321-4734-8d02-933835d88304.app.cloud.gov/site/gsa/datagov-11ty/maritime/hydrosurvey-data-archive-for-federal-navigation-projects/ >> resolves correctly because it lacks site/gsa/datagov-11ty/

Expected behavior

I expect relative URLs to resolve.

Actual behavior

Relative URLs give a 404 due to incorrect pathing.

Sketch

btylerburton commented 2 years ago

One recommendation was to find/replace {{ site.baseurl }} with {{ "path" | url }}, but that has not been tested.

btylerburton commented 2 years ago

11ty documentation

https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix

nickumia-reisys commented 2 years ago

The preliminary results from testing reveals:

nickumia-reisys commented 2 years ago

This is mostly done. It just needs a few more eyes and tests to see what's broken if anything.

nickumia-reisys commented 2 years ago

Fixed a few more bugs... The situations handled: