mitodl / ocw-hugo-themes

A Hugo theme for building OCW websites
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

support prefixed deployments in the www theme / search app #1365

Open gumaerc opened 8 months ago

gumaerc commented 8 months ago

Description/Context

In ocw-studio, you can use the upsert_mass_build_pipeline management command to generate a pipeline in Concourse that will build all publishable websites that ocw-studio knows about and deploy them. This command has an argument called --prefix. When this argument is set the prefix is applied to the baseURL argument when Hugo is run, and the site is deployed to the prefixed URL.

In the www theme, we have a number of hard coded links that do not respect the Hugo baseURL setting. Search results from the search app also do not respect this setting. So, in order for the prefixed sites to be fully self-contained, we will need another way to set the prefix so it can be respected when building a root website with the www theme.

Plan/Design

ibrahimjaved12 commented 8 months ago

Just confirming, should this be in Needs triage or Ready ?

gumaerc commented 8 months ago

Just confirming, should this be in Needs triage or Ready ?

As long as there isn't anything else high priority, I'd say you can grab it. I put it in "needs triage" because fixing this isn't really super critical. There are plenty of workarounds for viewing prefixed pages that aren't too frustrating to use, such as visiting pages directly. I put up the other PR in ocw-studio because it was an easy win. We only had to change a few lines of code to get Hugo to render the prefix. This one is a bit more complicated, and will require another PR in ocw-studio afterward to set the env variable mentioned above.

Another complication that comes to mind, now that I'm thinking about it, are the links built into search. Since we build theme assets once per branch of ocw-hugo-themes using the theme assets pipeline, then consume those with each site build, whatever env value is used during the theme assets build will determine what the links in search results are. So, it would be impossible to create two different prefixed builds pointing at the same branch of ocw-hugo-themes. I don't think this is something we would commonly do, if ever, but it does make the --prefix argument on the mass build pipeline a bit disingenuous because setting the prefix there would do nothing for the links in search.