Howto put a site inside a hugo site

i have a hugo site setup with a sites folder. i would like to put various complete sites inside that folder, so that

sites/index.org
looks something like this:
link to siteA
link to siteB

i tried this structure:
content/sites/index.org
content/sites/siteA/
content/sites/siteB/

where siteA and siteB have an index.html page and other html pages.

however, when i run hugo server, i can’t get to siteA or siteB even manually putting in
http://localhost:1313/sites/siteA/index.html

can i make this system work (other than manually editing things after generating public/)?

not sure what you are trying to achieve here because a site inside a site is still just a site… but whatever

you can create two separate Hugo projects, one for each site, and have each of them write the generated html pages to respective folders inside your “parent” site folder in which you can have a simple index.html with links to the index.html of each of the child folders

~/hugo-sitea → writes to ~/site/sitea/
~/hugo-siteb → writes to ~/site/siteb/
~/site/index.html
        |_ sitea/index.html
        |_ siteb/index.htlm

The only thing is, you won’t have a Hugo webserver running with both sites but you could run your choice of webserver (node httpserver, or python’s httpserver) in the ~/site folder and view your work

@punkish

thx for the info. i think you’ve clarified that the hugo server will not show my siteA and siteB (because they weren’t generated by hugo in the first place). i was of the opinion that anything inside the content/ would be accessible by hugo server.

those sites (A and B) are former projects that i want to be viewable through the main site (and i don’t want to redo them with hugo).

i can put them into public/ manually before publishing, link them in as you show above and it should be fine. i’ll also give a local server a try as per your suggestion.

perhaps I did that unintentionally, but it was not my intent. While I don’t recall having personally tried it, my (pretty good) guess is that Hugo won’t write over your pre-existing content. But, here is the thing… remember that when you run hugo server (with or without -D, it doesn’t actually write the pages to disk. It renders the pages in memory and serves them. Read the output of the command carefully… (note, the path name below is fictitious but everything else is real)

site git:(main) hugo server
Start building sites … 
hugo v0.92.0 darwin/amd64 BuildDate=unknown

                   | EN   
-------------------+------
  Pages            | 177  
  Paginator pages  |   7  
  Non-page files   |  80  
  Static files     |  19  
  Processed images |   0  
  Aliases          |  45  
  Sitemaps         |   1  
  Cleaned          |   0  

Built in 730 ms
Watching for changes in ~/site/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in ~/config/_default
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

So, the hugo webserver has no idea of your preexisting websites (sitea and siteb) on disk. Only when you ask hugo to write out your main site html to disk (by running just hugo) it will write the site a files. Then you use your own webserver to view all your sites

you are correct!!
thx for following up on this, because as a result of your reply, i rechecked how i’d setup my links and discovered that was the real problem!

here’s what works perfectly:

sites/
index.org
siteA/index.html
siteB/index.html

with index.org containing the links:
siteA/index.html
siteB/index.html

this works with hugo server!! big effort saver since i don’t have to manually put the sites into public/

i don’t even need to run a python server!
(of course, it works just fine with it in public/ as well.)
btw, if anyone doesn’t know how to get the python server working (i didn’t), just go into public/ (after running just hugo) and type:
python -m http.server
then follow the link the (eg http://0.0.0.0:8000/)

thx again @punkish !

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