I need to have two different themes in the same site, and I have been recommended to just have two separate static sites.
I just need someone to check that i have gotten the organisation and configuration correct. This is what the root directory will look like:
(the items with three dots in front of it is in "section2" directory)
The following is what the two config files look like:
```contentdir = "content"
layoutdir = "layouts"
publishdir = "public"
builddrafts = false
baseurl = "http://example.com/"
canonifyurls = true```
```contentdir = "section2/content"
layoutdir = "section2/layouts"
publishdir = "section2/public"
builddrafts = false
baseurl = "http://example.com/section2"
canonifyurls = true```
Assuming this is correct so far, the thing that i am having difficulty understanding is "content" and "public", specifically the difference between the two and understanding what "public" is, does, and where its located.
The content dir is the place where you store your *.md files you’re writing your content in. The public dir is the location hugo is building your site - all files here must be copied to your webspace. Your public dir is empty until your first build.
You will get two different sections by adding their dir to content:
But this only gives you different views for a single item (calling site.tld/section1/sec1post1 after upload) For getting your posts (secXpostY) shown in different places you’ll need a template themes/layouts/section1/index.html for a list view of all content in section1. And you should use just one config.toml, I think there is just one executed when calling hugo.
This is the way @moorereason told by putting complexity in theme (I hope…) - it’s just the one way I know. I have just no idea how to get this by deployment…
Yes this is one way to do it, but people have recommended to just set up two separate sites, and I think I would prefer this too. The only trouble I am having is knowing how to then setup the config file(s) and the baseurl(s) to make both separate static sites work under the same domain name.
OK, I’ll give it a new try after reading your other thread.
Make one site with your first layout with all your needed folders and files (layout, content, config.toml, …). This will generate a public folder. (call this site1 for here)
Now switch to another folder, create a new site will all folders and files - this will give you another public folder. (and this site2)
Now set in your config.toml for site1:
baseURL = "yourdomain.tld"
and in your config.toml for site2:
baseURL = "yourdomain.tld/site2"
Then upload the site1-public dir to your webspace. Create a new folder inside it called site2 (or whatever you have chosen in your config.toml for site2) and upload the site2 public dir into this subfolder.
But doing it this way it might get hard to create links dynamically between your two sites. I think it’s not possible to create two different sites by just calling hugo one time - for deployment in this version you might create a script for calling hugo on both (site1 and site2), merging your public dirs in the correct way and upload the files. You have to decide, which option you will take - I can’t see a recommendation in his words…
This is very important to know, so thanks for this.
Yes, if I decide to choose separate sites first then it may be that I switch to putting the complexity in the theme later on. However I will go away and think about it first. I will be referring to your post:
Create two different sites in two different folders and merge (maybe by specifying the publishdir in the correct way for one or both of your sites) the output.
Use the section1 section2 method and write different layouts for them and create just one site.
The structure of folders you suggested in your first post in this thread - I don’t believe that this will work without problems. You’ve got nested folders but two completely separated sites in it, sounds strange for me.
Just play around for while with very simple layouts, just some kind of a “hello world” and find out what fits best to your needs.
The main reason for originally wanting to use two separate sites is that Section2 is going to get updated regularly whilst the rest of the site is going to rarely be changed. Is this a good enough reason to use separate sites, or is the more a job for Git Subtree?? Im thinking mainly in relation to rebuilding the site every time a change in Section2 occurs, would there be little disadvantage to just use a single site and just rebuilding the site again every time there is an update/change??
Assuming that I have chosen the single site option, I have two different themes, can you explain how I should organise the Source directory.
I dont know whether both themes should go together in the Themes folder, or whether they should be put in the Static and Layouts folder, with both themes’ Static files going in the Static folder, and both themes’ HTML files going in the Layouts folder.
Yes, thats what I was using as my guide. What is throwing me off is that your file structure uses a “themes” folder which in turn has “layouts” subfolder (and presumably static folder?). My question is should I put the static folder and layouts folder in the themes folder or should they be in the root folder (which I think is the conventional structure)??
Thank you for this, this sets me in the right direction, but at no point does Hugo Docs explain what the difference between
Its says if one folder is empty it then uses the next one in priority. It doesnt say when to use one over the other, or the advantages of using one over the other, just like if you have TWO themes with two different static folders and two different html, where to actually put this, or where you could or should put this.
This whole entire thread exists because Hugo Docs simply doesnt explain properly how to actually use Hugo.