What command do I need to use to generate the static site with theme?

According to Quickstart guide, I can use “hugo server --theme=hyde --buildDrafts” to run the hugo site with the theme that I wanted.

But I already have a web server on my host machine so all I want is just to generate the static site with the theme. I look at the files under /public/ folder. I found my posts and etc. but no theme.

Did you download that theme to your project folder?

There’ a few things (you probably know some of them already).

  • as @RickCogley said, you need to download the themes from github. How
    to do that is in the documentation in ‘installing themes’ (post again
    if that process isn;t clear).

  • when you use a theme it does not create a theme folder in ‘public’,
    it just uses the theme to build the site with that layout

  • you can run “hugo --theme=hyde --buildDrafts” (without server) to
    just build the public folder to run in your own webserver

  • also the Hugo command you are using assumes the downloaded themes are in your project folder. I change this to put all the themes in my main hugo folder 'so I put 'theme="…/themes/THEMENAME" in my config so i don’t need it in the build command.

I downloaded the theme. That’s why when I run hugo server. I can see the hugo blog with theme. But when I launch Index.html from public folder, I don’t see the theme. I will try what @mikeaja suggested. Thanks!

Hi @mikeaja I tried runing ““hugo --theme=hyde --buildDrafts””. but when I double-click on “public/index.html” then I don’t see the blog with theme. Yes. I have themes downloaded under theme folder. Do I need to manually edit the “public/index.html” to link with theme?

1 Like

There are very likely others with more experience than me who can help better.

I don’t understand this part. What is there will be the result of what is used from the theme, what is in your project’s ‘layouts’ folder, how that connects with the sections your content is in, and perhaps what is in your contents front matter (if you’ve specified any ‘Type’ for the content, which is not necesary)…

What’s in Public is what’s generated, so you don’t want to change anything there.

The double click part doesn’t work out of the box … This has to do with the reference to external resources (stylesheets etc.). You need to run it on a server (or use relativeURLS=true should also work… but that is outside scope of this question).

1 Like

Thanks @mikeaja

I don’t change anything. I followed quickstart to create the site and post. and downloaded the theme. I tested the site by running the server. It works well…

But I don’t want to run the server since my host already have IIS. All I want is the static site. The idea is that to write the post in my laptop and commit the change to my git repository (I will put everything under public folder to the git repo). And then I will upload those js,css, image and html files to CDN or Azure Blog storage. The problem now is that I need to run the hogo server to make my blog working. I don’t understand why hugo has such a requirement. I just look for static blog generator or engine. not a web server.

1 Like

@bep

Thanks for the confirmation! Is there any way to make it work?

My main concern is that I don’t want “hugo server” to host my blog. I already have the web server. Or, I like to upload all static contents (the whole blog) to CDN so I don’t need the hugo webserver.

Thanks!

Not sure if I’m missing something here. Hugo creates static sites. You could develop and build sites with Hugo without ever having to use the ‘server’. It is there just to make life simpler for local developing and making changes, not as a hosting server.

@mikeaja

Let me try again. As @bep mentioned, the double click part doesn’t work out of the box.

I think I might be missing something as well. My goal is to generate the site and host all those static contents (post, html, js, css, images and etc.) on CDN or S3 or Azure blog storage.

I am very new to Hugo so I followed this quickstart https://gohugo.io/overview/quickstart/ until the step 5.

Those steps are ~

  • Downloaded the hugo. renameed hugo-version.exe to hugo.exe and added it to %PATH% on windows.
  • hugo new site /path/to/site
  • cd /path/to/site
  • hugo new about.md
  • hugo new post/first.md
  • git clone --recursive https://github.com/spf13/hugoThemes themes OR git clone https://github.com/spf13/hyde themes\hyde if you want to download only one theme.
  • hugo server --theme=hyde --buildDrafts

It’s working fine. 2 pages are created and I am able to see my blog with two pages and theme via http://localhost:1313.

The problem or the confusion started here.

I wanted to upload that ‘public’ folder to my web server via FTP. So, I stopped the hugo server by pressing control + C and exit the commandline.

And then I double click on mysite\public\index.html. When the html page showed up on browser, there is no theme. So, if I upload the ‘public’ folder only to my web server that doesn’t have go installed, it won’t work.

Is it clear what I am trying to do?

1 Like

As I am a new user, I have no permission to upload the screenshot.

I tried create a virtual directory (website) in IIS on my local machine and point that site to mysite\public\ folder. When I access that site from Chrome, I got the same result (naked HTML page without a theme).

What do I need to upload if i want to host my static site generated by hugo on my web server? Uploading the ‘public’ folder is not good enough.

That’s not how the web works. Double clicking on it is not running it in any local server so it’s not a good test of what will after upload. (This is why there local servers are used in development).

If you see the site correctly with Hugo server, then Hugo has done it’s job. It means the site is being correctly built in Public (and running Hugo without ‘server’ builds it for production use - see docs). The rest is outside the scope of Hugo.

Virtual directories on IIS are there to create separated application spaces for when you need more than one app (dll) on the server. This is nothing to do wiith static sites.

My advice is (and I hope this does not sound bad or patronising, it’s not my intention) take a crash course in how HTML (and connected files) are served on the web and IIS. Bear in mind, most online info and tutorials will be assuming you are using a Linux / Apache server, so you need to translate that stuff to what it means for IIS (for example, htaccess).

@mikeaja

Yes and No. IIS can definitely serve the HTML page (static site). The static site (html) can be served on any web server (IIS, Apache, nginx and etc.) .

Of course, IIS supports .NET 2.0 or .NET 4.0 by default. You can run classic asp with ISAPI extension or run php with php extension. but it doesn’t mean that you can’t host the static site (html + js + css) on IIS.

Thanks! You can probably look at my blog http://michaelsync.net/ or my linked-in https://au.linkedin.com/in/michaelsync . I’m sure that I know about IIS and web. :wink:

I saw some people are using CI/CD (Continuous integration/Continuous delivery). I haven’t tested them yet because uploading the generated folder should be enough. Thanks for the advice. I will find that doc and will play around.

Thanks,
MS

Okie. I managed to solve it.

I missed out one step to update my localhost:port as baseURL in config.toml. and run hugo command again. and it works on both doubl-clicking index.html or IIS.

Thank you all!

1 Like

There isn’t any yes and no. What I wrote is what virtual direcctories are designed for :)… I think you missed my point. You said you’d set up virtual directories to solve the issue, but these are not relevant to static sites working on IIS (being able to use IIS for static sites was not in question).

Anyway, glad you got it working.

I had a very similar problem but the prototype I am working with does not use hugo themes; it is nano theme/asset in static. it rendered fine with hugo server but not when generating output to public. adding relativeURLS=true to config_en.toml worked.

1 Like