Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize baseUrl paths #26

Merged
merged 1 commit into from Oct 15, 2018
Merged

Normalize baseUrl paths #26

merged 1 commit into from Oct 15, 2018

Conversation

@0xazure
Copy link
Contributor

@0xazure 0xazure commented Oct 15, 2018

Use hugo's built-in absURL function to produce correctly formatted absolute URLs instead of manually concatenating separators.

This is mostly an aesthetic change as browsers correctly understood the malformed URLs for the most part. Before, the template would produce URLs such as:

  • <a class="pure-button" href="http://localhost:1313//index.xml">[...]</a>
  • <a class="post-category post-category-open source" href="http://localhost:1313//categories/open-source">open source</a>

(note the double slash after the port number).

It seems as though hugo's .Site.BaseURL already contains a trailing slash, which would double up when building a path using e.g. {{ .Site.BaseURL }}/categories/{{ . | urlize }}.

This fix uses hugo's built-in absURL and printf functions to build correctly delimited absolute URLs for various links and resources, producing URLs such as:

    • <a class="pure-button" href="http://localhost:1313/index.xml">[...]</a>
  • <a class="post-category post-category-open source" href="http://localhost:1313/categories/open-source">open source</a>

(note the single slash after the port number).

Use hugo's built-in absURL function to produce
correctly formatted absolute URLs instead of
manually concatenating separators.
@dplesca dplesca merged commit d6e7e2e into dplesca:master Oct 15, 2018
@dplesca
Copy link
Owner

@dplesca dplesca commented Oct 15, 2018

Hi,

Thanks for taking the time to add this pull request. It has now been merged.

@0xazure 0xazure deleted the 0xazure:normalize-site-paths branch Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants