alanorth / hugo-theme-bootstrap4-blog

A blogging-centric Bootstrap v4 theme for the Hugo static site generator.
Other
204 stars 132 forks source link

Support baseurl without trailing slash #110

Closed vincevriend closed 5 years ago

vincevriend commented 5 years ago

Using a baseurl without a trailing slash such as baseurl = "https://example.org" will generate invalid links in the HTML.
For example this baseurl will generate this incorrect url to the stylesheet href="https://example.orgcss/style.css".

This PR replaces the fragile .Site.BaseURL construction with the Hugo absURL function to generate urls. The documentation mentions trailing slash behaviour:

absURL and relURL are smart about missing slashes, but they will not add a closing slash to a URL if it is not present.

When you use netlify to host a hugo site netlify can create deploys for feature branches and pull requests. These specific deploys get an automatically generated url which you can access with environment variables such as DEPLOY_URL and feed into the hugo invocation. The environment variable values do not include a trailing slash so the site will break when using hugo-theme-bootstrap4-blog.

alanorth commented 5 years ago

Great contribution. Thanks, @TommySprat.