Repository: gohugoio/hugo (language: go)

Issue:
tpl/urls: absURL and absLangURL strip query and fragment
### What version of Hugo are you using (`hugo version`)?

hugo v0.120.4-f11bca5fec2ebb3a02727fb2a5cfb08da96fd9df+extended darwin/arm64 BuildDate=2023-11-08T11:18:07Z VendorInfo=brew

### Input

```html
{{ "/search/?from=sitelinks&q={search_term_string}" | absURL }}
```

### Expected output

```html
http://example.com/search/?from=sitelinks&q={search_term_string}
```

### Actual output

```html
http://example.com/search/
```



Discussion / hints:

Fix patch:
diff --git a/common/paths/url.go b/common/paths/url.go
index cefefdf11b7..093ba9ff7fa 100644
--- a/common/paths/url.go
+++ b/common/paths/url.go
@@ -71,6 +71,8 @@ func MakePermalink(host, plink string) *url.URL {
 	}
 
 	base.Path = path.Join(base.Path, p.Path)
+	base.Fragment = p.Fragment
+	base.RawQuery = p.RawQuery
 
 	// path.Join will strip off the last /, so put it back if it was there.
 	hadTrailingSlash := (plink == "" && strings.HasSuffix(host, "/")) || strings.HasSuffix(p.Path, "/")


Test patch:
diff --git a/common/paths/url_test.go b/common/paths/url_test.go
index 4e5f7305389..5a9233c26fa 100644
--- a/common/paths/url_test.go
+++ b/common/paths/url_test.go
@@ -31,6 +31,7 @@ func TestMakePermalink(t *testing.T) {
 		{"http://abc.com", "bar", "http://abc.com/bar"},
 		{"http://abc.com/foo/bar", "post/bar", "http://abc.com/foo/bar/post/bar"},
 		{"http://abc.com/foo/bar", "post/bar/", "http://abc.com/foo/bar/post/bar/"},
+		{"http://abc.com/foo", "post/bar?a=b#c", "http://abc.com/foo/post/bar?a=b#c"},
 	}
 
 	for i, d := range data {