Home network access to hugo site

hi.

Beginner alert.

Have set up a hugo site using the terminal theme and have it visible on

hugo server

This is the screenshot on the computer where hugo server is running.

So far so good.

image removed - one image only

I wanted to see if I could access this from a browser on the same home network, but http://192.168.1.137:1313 received “this site can’t be reached”.

Maybe there’s a way to configure hugo server…

Then set up apache2 on server, and tried same access from same client, and got the default apache index.html.

Then, copied the results of

hugo

to /var/www/html

The hugo website is being accessed, but no formatting…

What am I doing wrong?

Cheers

boogy

This is the view of the website with the proper formatting.

this is the start of the config.toml

baseURL = “http://example.org/
languageCode = “en-us”
title = “hugo terminal theme”
theme = “terminal”
paginate = 5

This is a better picture of accessing the apache2 from a client computer on the same network, with the url used:

The Terminal theme CSS is an absolute URL (have a look here: https://github.com/panr/hugo-theme-terminal/blob/master/layouts/partials/head.html).

Your 192.168.1.137 website probably use a http://example.org/assets/style.css.

So change your baseURL in your configuration file with your local IP.

1 Like

Thank you @nfriedli.

Just got back to your post after looking at View Page Source on the hugo server version and seeing example.com/… all over the place.

Perfect timing. Am now seeing properly rendered site locally and from other computers on the network. So when moving to a hosted service, this will be a critical setting. Not sure if all themes will work this way.

1 Like

You can use multiple configuration files for direct hugo server (on your own computer), developement (on your local network apache) or production (on your hosted service). Have a look at this doc: Configure Hugo | Hugo

Thanks @nfriedli that page is starting to make more sense now. It’s a classic loop of learn-do-fail-learn… Still not sure if ‘hugo server’ has the capability to be used as a local server for the home network, but apache2 is probably a more realistic option as it may be used in a live situation…

There is perhaps a better solution, just for you: use only relative URLs.

As your website is on your Apache’s root, you can use | relURL filter instead of | absURL filter in your theme. And add a relativeURLs : true in your configuration file. You have to modify the theme.

So you can use exactly the same website with your local hugo server, your Apache and the production website (if the production website is on the root).

1 Like

So, if “grep -ri absURL” is used in the theme folder, it returns about 15 finds, so making your suggested change would mean the baseURL value wasn’t used at all.

Yes… and no. There are abs URLs, for example in the opengraph internal template (https://github.com/gohugoio/hugo/blob/01e249e97ce9a3bc145f4372a032b9da3e123a62/tpl/tplimpl/embedded/templates.autogen.go). Or twittercards template, schema template, etc.

I think you should always use a correct baseurl…

Using the correct baseurl was my conclusion too! There’s a difference between learning how something works and making a change just because it can be made. As a beginner, it doesn’t feel right to change a theme directly.

My strategy, in the absence of knowing how to choose a theme, is to try out a number of themes in order to learn about how Hugo works (add to that: learn about a lot of other topics, including git, networks, etc).

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.