Reputation: 1601
I have a github repository that I want to add my hugo site to. From the docs folder in my repository I can run github pages.
Therefore, I have changed my publishDir
parameter in the hugo config to docs
.
publishDir = "docs"
Now when I build hugo it ouputs everything in the docs folder which is great, the issue is running a subdomain from there.
How do I get a subdomain on hugo that is generated into my docs folder that acts like a subdomain on github pages?
I know I would need to use a CNAME and then tell it to say /docs/subdomain
is actually subdomain.site.com
but I am not sure how to set that up in HUGO. and where do I put the subdomain folder? in the static folder so it would be theme_name/static/subdomain
which would ouput into the docs like docs/subdomain
?
If this is the way, can I use all the parameters and shortcodes in my static folder?
Also, if I need to create 2 hugo installations, one for the main site and one for the subdomain site, is their a way to share site params, configs, static files and layout files etc… ?
Upvotes: 3
Views: 1323
Reputation: 469
If you have two sites that you want to serve separately under two domains/subdomains (or even subpath), it's better that you create two different repositories for that.
In your username.github.io repository, you are using the "docs" folder to serve your site. However, this procedure will not work for other repositories. To serve from other repositories, name the repo whatever you like and create a "gh-pages" branch on it. The branch root must contain the entire site. You can access this site using username.github.io/your-repo-name/.
In this new repo you can add a CNAME. Hope this works. I did almost the same thing, except that I used subpaths instead of subdomains. Here's my main profile rafed.github.io and my blog rafed.github.io/devra/
Upvotes: 0
Reputation: 127
You have to create a custom script to create two different builds and then
Add a CNAME file to your project's repository. The content of this file must be a single line specifying the bare subdomain for your project's custom subdomain (e.g. pjname.mydomain.com). In your DNS provider's settings, create a new CNAME record that points project name to either the root (usually denoted by @), if you have previously set up an apex domain, or to myusername.github.io if you've set up a custom subdomain. It should look something like this:
Upvotes: 0