# path.Join gives inaccurate results when there is https or http prefix

**URL:** <https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868>\
**Category:** support\
**Created:** [October 17, 2020, 9:21am UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868 "2020-10-17T09:21:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wcc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wcc/32/12523_2.png) [@wcc](https://discourse.gohugo.io/u/wcc)\
**Post date:** [October 17, 2020, 9:21am UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868/1 "2020-10-17T09:21:38Z")

</div>

When I want to use join a path like “[https://github.com/someone/some-project](https://github.com/someone/some-project)” and “blob/master”, the result is like “https:/github.com/someone/some-project/blob/master”.

I guess `path.Join` just removes repeated slashes? So it will get a wrong result when a prefix like `https://` or `http://` exists. And can we adapt it so that it can behave well when those prefix exists? Or I just used the wrong method?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [October 17, 2020, 9:40am UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868/2 "2020-10-17T09:40:18Z")

</div>

A path is a local path, not an URL. That’s probably the error in thought. I would do something along the lines of `printf ("%s%s" .Site.baseURL “/blob/master”)

---

<div class="post-metadata">

**Author:** ![wcc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wcc/32/12523_2.png) [@wcc](https://discourse.gohugo.io/u/wcc)\
**Post date:** [October 17, 2020, 9:46am UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868/3 "2020-10-17T09:46:52Z")

</div>

Ok, got it. Thank you so much!

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [October 17, 2020, 12:37pm UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868/4 "2020-10-17T12:37:47Z")

</div>

That said, I would recommend using the built-in funcs for this, e.g.:

```auto
{{ “/blob/master” | absURL }}
{{ “/blob/master” | relURL }}

```

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 19, 2020, 12:37pm UTC](https://discourse.gohugo.io/t/path-join-gives-inaccurate-results-when-there-is-https-or-http-prefix/28868/5 "2020-10-19T12:37:51Z")

</div>

Closed on October 19, 2020, 12:37pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
