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

Sitemap creation in public folder using localhost as url when running "hugo server" #1455

Closed
dnosker opened this issue Sep 23, 2015 · 3 comments
Labels

Comments

@dnosker
Copy link

dnosker commented Sep 23, 2015

When running command line "hugo" all is fine and the .Permalink in the hugo default template is creating the correct urls in the sitemap using the baseurl set in the config file.

However, if running "hugo server" the sitemap is generating instead this:
http://localhost:1313/about/

The problem is that IF the last command ran is "hugo server", and then the sitemap in the public folder is transferred to a remote webhost, the sitemap will have invalid links.

Suggesting this be changed to always use the baseurl set in the config for sitemap generation even when running "hugo server" on a local machine.

@anthonyfok
Copy link
Member

Hi @dnosker,

Thank you for your suggestion.

However, the behaviour you are seeing is by design. The http://localhost:1313/ baseURL is necessary for your web browser to find the files served by hugo server. If you look closely, it is not only sitemap.xml, but ALL generated HTML are likely to contain hrefs pointing to "http://localhost:1313/", so something is bound to be broken (missing CSS, missing images, etc.), making it unfit for upload to the production server anyway.

Also, end users often run hugo server --watch, which injects LiveReload.js to the web page for instant update to ease web development. This feature is great for the local computer, but not for production.

So yes, it is imperative that a final "hugo" run be made to generate a correct website for upload to the production web server.

Alternatively, with the appropriate command-line flags, "hugo server" _can_ be used as _the_ web server on your production server. See https://gohugo.io/overview/usage/#alternatively-serve-your-web-site-with-hugo:dc32fe45042973266ca60588597e0b66 for more information.

Cheers,
Anthony

@bep bep closed this as completed Sep 24, 2015
@dnosker
Copy link
Author

dnosker commented Sep 24, 2015

Thanks for the help... I was using "hugo" without the same --VARS as when running "hugo server" on the end. Once I set them the same all is well with this.

@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 Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants