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

Make Hugo Deploy respect custom MediaType/OutputFormat #6861

Closed
virgofx opened this issue Feb 7, 2020 · 3 comments · Fixed by #7531
Closed

Make Hugo Deploy respect custom MediaType/OutputFormat #6861

virgofx opened this issue Feb 7, 2020 · 3 comments · Fixed by #7531

Comments

@virgofx
Copy link
Contributor

virgofx commented Feb 7, 2020

config.xml

[outputs]
  home = ["HTML", "RSS", "WEBMANIFEST"]
[mediaTypes."application/manifest+json"]
  suffixes = ["webmanifest"]
[outputFormats.webmanifest]
  name = "webmanifest"
  baseName = "site"
  mediaType = "application/manifest+json"
  rel = "manifest"

layouts/home.webmanifest


  1. hugo build

  2. Confirm: ./public/site.webmanifest

  3. Curl Check ✓

    curl -I localhost:3000/site.webmanifest
    HTTP/1.1 200 OK
    Accept-Ranges: bytes
    Content-Length: 1202
    Content-Type: application/manifest+json; charset=utf-8
    Last-Modified: Fri, 07 Feb 2020 04:07:27 GMT
    Date: Fri, 07 Feb 2020 04:18:13 GMT
    

    Hugo dev server is serving file with appropriate content type ✓

  4. Now lets deploy ....

    yarn deploy
    ...
    Uploading site.webmanifest (501 B, Content-Encoding: "gzip"): not found at target...
    

    X Confirmed the content type on server is: "application/x-gzip"

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.63.2-934EE21F/extended linux/amd64 BuildDate: 2020-01-27T12:20:42Z

Does this issue reproduce with the latest release?

Yes

@virgofx
Copy link
Contributor Author

virgofx commented Feb 7, 2020

Side note and maybe related --- I'm noting my XML files are set as application/xml and served that way locally via Hugo dev server; however, when deployed, they're converted to text/xml. So just seems the deploy is getting content-types from somewhere else maybe?


Edit/Answer: See below comment. It's falling back to TypeByExtension

@virgofx
Copy link
Contributor Author

virgofx commented Feb 7, 2020

Checked the code ... there's a TODO to incorporate the MediaTypes just as I suspected. It must be done already in the dev server but is currently being skipped and jumping to TypeByExtension.
https://github.com/gohugoio/hugo/blob/master/deploy/deploy.go#L408-L410

Workaround
Use the custom matcher ContentType to specify an explicit content type.
(Note: This isn't in any of the documentation. Would be nice to have that in the docs instead of searching the code.)

@bep bep added the Enhancement label Feb 7, 2020
@bep bep added this to the v0.65 milestone Feb 7, 2020
@bep bep changed the title Hugo Deploy Doesn't Respect Custom MediaType/OutputFormat Make Hugo Deploy respect custom MediaType/OutputFormat Feb 7, 2020
@bep bep modified the milestones: v0.65, v0.66 Feb 18, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.68, v0.69 Mar 20, 2020
@bep bep modified the milestones: v0.69, v0.70 Apr 8, 2020
@bep bep modified the milestones: v0.70, v0.71 Apr 28, 2020
@bep bep modified the milestones: v0.71, v0.72 May 18, 2020
@bep bep modified the milestones: v0.72, v0.73 May 31, 2020
@bep bep modified the milestones: v0.73, v0.74 Jun 23, 2020
@bep bep modified the milestones: v0.74, v0.75 Jul 13, 2020
satotake added a commit to satotake/hugo that referenced this issue Aug 2, 2020
@bep bep closed this as completed in #7531 Aug 3, 2020
bep pushed a commit that referenced this issue Aug 3, 2020
asankah pushed a commit to asankah/hugo that referenced this issue Aug 16, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants