6

I have a hugo theme based website that I am hosting from gitlab at myusername.gitlab.io, and then I have another smaller website based on hugo themes at myusername.gitlab.io/repoA, that I would like to add from my previous website, at a url like myusername.gitlab.io/repoA

Now, here is my question ( I have not done this a whole lot, so please forgive my ignorance.)

  1. Would it be easier for me to do a url, like username.gitlab.io/secondwebUrl ? (Do I need to still do custom domains, generate new certs and add them to gitlab ?)
  2. Would it be easier for me to just create a sub-domain ( just to clarify, I am hosting using google domains and SSL via cloudflare) ?
MithunS
  • 485
  • 7
  • 28
  • So do you wanna have two projects (blogs) and inject one inside the other without doing nothing else than redirecting with your subdomain? I don't understand the complete picture you want to achieve – charly3pins Oct 10 '18 at 09:08
  • The main website is built using one hugo theme, a second smaller single page is built using another hugo theme. That second page is just a relative url, so lets say if www.example.com is the main website, the second site (which itself is a hugo website) has to live at example.com/aboutUs or aboutus.example.com I wish to know, which way is easier and how to do it , do I need to just make my own custom hugo theme or do short-codes or write my own partials ? – MithunS Oct 10 '18 at 19:26
  • I think the best way to do is using a subdomain, because if you go to example.com/aboutUs , will find the templates in your main web/theme, so using the subdomain you'll fix that. However, if you want only a single page why you don't mix the themes? – charly3pins Oct 10 '18 at 20:11

1 Answers1

5

Analyse build-output of themes

You have to analyze the output files, your individual themes produce. For example:

Theme A produces:
   -- index_1.html
   -- style_1.css
Theme B produces:
   -- index_2.html
   -- style_2.css

Write a simple script

Hugo does not support post-run scripts, so the simplest way to stack two sites into one another is to write a small shell script like:

 cd /path/to/themeA
 hugo themeA --destination=/deploy/location/

 cd /path/to/themeB
 hugo themeB --destination=/deploy/location/about/

This will result in a layout looking like this:

 /deploy/location
    -- index_1.html
    -- style_1.html
    -- about/
       -- index_1.html
       -- index_2.html

This resulting directory can be deployed to your hoster by whatever method you have to use.

Repair potentially broken links

Now you can simply look at the resulting page, making it easy to identify broken links and change them in the html of your local hugo template.

Do not use a subdomain

Using a subdomain for this seems highly unnecessary. Certificates are only needed for new (sub-)domains.

Sheppy
  • 330
  • 1
  • 10
  • How is this different from just running hugo manually on child theme project and copying and referencing html files directly. I have tried that and that approach does not work. – MithunS Oct 13 '18 at 14:31
  • it's not, and it does work, I'm doing exactly that on my own project, im sure if you go into the browser console on the resulting page you will see failed requests of some sort – Sheppy Oct 14 '18 at 10:18
  • Yes, there are multiple resource access failed requests for the child website. True. – MithunS Oct 15 '18 at 15:07
  • Now just prepend the relevant path in the html-template like for example *about/* – Sheppy Oct 16 '18 at 14:41