Exposing localhost:1313 using a domain name publicly using cloudflare tunnel?

My blog name is example.com. I mapped in cloudflare tunnel for any requests in blog.example.com to localhost:1313.

blog.example.com displays my home page. But when I click on a post it redirects to localhost:1313 in URL instead of blog.example.com/posts/abcd.

Can anyone help me understand the architectural designs?

This seems to be the issue.

When running hugo server the “baseURL” is set to localhost since it is ment for local development.

You can override this with hugo server --baseURL=https://blog.example.com/

But, the hugo server is not built for production, only for development,

1 Like

Learnt a new thing today. Does it mean I should run a different web server like LAMP, LEMP instead of hugo? I really like hugo’s themes. Is there a way to use it and also not use hugo server in production? It’s a hobby project so it really doesn’t matter, but I want to be production ready.

Hugo is a “static site generator”. You run the hugo command and Hugo build your site and place all the files in the “public” directory.

These files you then upload to whatever web hosting service you prefer.

See Hosting and deployment | Hugo for tips regarding different services.

Personally I mostly use GitHub pages for hosting. With GitHub actions you can have GitHub build the site and publish it automatically on each new commit.

It’s already hosted on github pages, I want to have full server access root access I mean.

Why do you want to run Hugo server if your pages are served from GitHub pages? I don’t understand what you’re after here.

Because my goal is not to be a blogger. But to understand operations of website on my own. I’m revoking my github pages and transferring it to self hosted.

Yes. I’d recommend Apache or NGINX.

Hugo’s development server (started with the hugo server command) is a development server, not a production server. It is intended to help you with development activities such as creating and editing content and templates.

2 Likes