Add dynamic pages to a static website built with Hugo

Hi everyone,

I know that hugo is a static site generator . Comparing NextJs to Hugo, Nextjs has additional features to pre-render the page on the server using getServerSideProps.

I have an application where most of the pages are static and if I need to have some dynamic features, I can rely on javascript for that. But I’m wondering if the application requirements have changed and server-side rendering is needed on certain pages? How can I implement it with Hugo?

I like Hugo over Nextjs, because it gives a lot of features out of the box, but I don’t want to be stuck if ssr is needed in the future.

One possible way that came to mind is to create my own server using nodejs, dotnet or which ever framework and serve Hugo generated html files + implement ssr on some other pages.

Is this a good approach?
Do you have any working codebase which serve as an example?

Thank you

There is no example of what you are trying to do as far as I know.
Hugo is not designed to publish pages that are rendered server side.

Hugo can render data from external APIs with getJSON and getCSV.

Hi thanks for your reply.
My idea is:
1-keep using hugo to generate my static files.
2- add hugo generated files to the public directory of my server

That way, if the user requests a static page, will serve the page from the public directory otherwise will handle the request and generate an html page

Just thinking if we want to add authentication to a static site, would the only option be to use javascript to render the dynamic part that are specific to the user (client-side rendering) Or can we generate the page using the steps above?

Your question is kind of OT here because Hugo simply ouputs static HTML along with its assets.

Please try asking in a forum that accepts general questions about server configuration and user authentication.

1 Like