mitodl / ocw-studio

Open Source Courseware authoring tool
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

fix links in prefixed sites built with the mass-build-sites pipeline #2121

Closed gumaerc closed 7 months ago

gumaerc commented 7 months ago

What are the relevant tickets?

Closes https://github.com/mitodl/ocw-studio/issues/2113

Description (What does it do?)

This PR takes the prefix argument being sent to SitePipelineDefinition and in addition to prefixing the S3 path with it, the Hugo baseURL argument is now also prefixed. This means that links rendered inside of sites deployed at a prefix URL will correctly link you to the prefixed page, at least for content generated by Hugo.

How can this be tested?

gumaerc commented 7 months ago

@ibrahimjaved12 Thanks for your review. I looked into home page links, and I believe it's a bit beyond the scope of what this PR is doing. This PR simply sets the Hugo --baseUrl parameter to include the prefix. This means that links generated by Hugo (.Permalink, .RelPermalink, pageRef) will contain the prefix and work as expected. However, The links to the search page are mostly hard coded in ocw-hugo-themes to be relative to the root of the site. I think that in order to support this, we would need a PR in ocw-hugo-themes to be able to pull the prefix from an env variable and set it where necessary. This especially applies to the links within the search page itself, as the search page is a separate React app not generated by Hugo.

gumaerc commented 7 months ago

I created an issue here for adding support to the www theme for prefixed deployments: https://github.com/mitodl/ocw-hugo-themes/issues/1365