Skip to content
New issue

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

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

Already on GitHub? # to your account

hugo server fails to serve the site when baseURL contains a subpath without hostname #7823

Closed
yihui opened this issue Oct 12, 2020 · 4 comments
Labels

Comments

@yihui
Copy link
Contributor

yihui commented Oct 12, 2020

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

$ hugo version
0.76.4

Does this issue reproduce with the latest release?

Yes.

Reproducible example

Here is a small reproducible example: server-baseurl.zip

In config.yaml, it has baseurl: "/subpath/". Then we run hugo server:

Start building sites … 

                   | EN  
-------------------+-----
  Pages            | 32  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  2  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Built in 87 ms
Watching for changes in .../{content,layouts,themes}
Watching for config changes in .../config.yaml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313///subpath/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Open http://localhost:1313///subpath/ and it shows 404 not found. http://localhost:1313/subpath/ and http://localhost:1313 don't work, either.

It works if I specify the full URL like baseURL: http://example.org/subpath/, but I prefer not hardcoding the protocol or domain in the base URL.

@bep
Copy link
Member

bep commented Oct 12, 2020

That is not a valid baseURL.

@yihui
Copy link
Contributor Author

yihui commented Oct 12, 2020

I'm sure it worked before, although I'm not sure which version of Hugo broke it. Being able to set a base URL without the protocol or hostname makes the generated website more portable, i.e., the site can be moved to any domain and works with any protocols.

@yihui
Copy link
Contributor Author

yihui commented Oct 12, 2020

Okay, it seems to work again if I remove the leading slash, i.e. use baseURL: subpath/ instead of baseURL: /subpath/. I'm closing this issue for now. Thank you!

@yihui yihui closed this as completed Oct 12, 2020
yihui added a commit to rstudio/blogdown that referenced this issue Oct 12, 2020
…name or protocol, add a fake https://example.org/ to make Hugo know that the site is to be generated under a subpath
@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 27, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants