Hi there,
I apologize if this is a known issue or if we are simply not using Hugo properly, but I am having an issue with the --baseURL
CLI argument. First, some context:
I am building a site using the “course” theme from this repo: GitHub - mitodl/ocw-hugo-themes: A Hugo theme for building OCW websites
We keep the content for course sites in their own separate repos; this is an example: GitHub - gumaerc-testorg/10.01-spring-2020-2
We keep our Hugo config files in a separate repo here: GitHub - mitodl/ocw-hugo-projects: A collection of Hugo project templates for different types of OCW websites
We have an instance of Concourse (a CI/CD platform) that handles running builds and deploying the site. Course sites are built individually and placed in a subfolder of a larger website, and --baseURL
is set at build time to ensure links all point to the right place. When the Hugo command is run, it looks something like this:
hugo --themesDir ../ocw-hugo-themes/ --config ../ocw-hugo-projects/ocw-course-v2/config.yaml --baseURL /courses/10-01-ethics-for-engineers-artificial-intelligence-spring-2020 --destination output-online
I’m currently testing upgrading our build to use Hugo 0.112.6, and we’re currently using 0.111.3. When I run the above command using Hugo 0.112.6, links on the site are rendered without the --baseURL
setting. For example:
root@595900b2-97e0-4792-4202-cff2b2805295:/tmp/build/b74a5319/course-markdown# cat output-online/index.html | grep syllabus
<meta name="keywords" content="opencourseware,MIT OCW,courseware,MIT opencourseware,Free Courses,class notes,class syllabus,class materials,tutorials,online courses,MIT courses">
href="/pages/syllabus">
href="/pages/syllabus">
When I switch the Hugo version back to 0.111.3, the links render properly:
root@595900b2-97e0-4792-4202-cff2b2805295:/tmp/build/b74a5319/course-markdown# cat output-online/index.html | grep syllabus
<meta name="keywords" content="opencourseware,MIT OCW,courseware,MIT opencourseware,Free Courses,class notes,class syllabus,class materials,tutorials,online courses,MIT courses">
href="/courses/10-01-ethics-for-engineers-artificial-intelligence-spring-2020/pages/syllabus">
href="/courses/10-01-ethics-for-engineers-artificial-intelligence-spring-2020/pages/syllabus">
Here is an example of this course on the live site: Ethics for Engineers: Artificial Intelligence | Chemical Engineering | MIT OpenCourseWare
Is there something wrong with the way we’re using the --baseURL
setting here? The documentation says that it should have the full domain and protocol, but using it this way has always worked for us until now. I did try setting --baseURL
to a fully qualified URL and that did not work either. Either way, it seems something in 0.112.x has broken this for us and I’m confused as to why.