espinosajuanma / juanma.ar

Juanma's personal website
0 stars 0 forks source link

Migrate from Astro to hugo #14

Closed espinosajuanma closed 7 months ago

espinosajuanma commented 7 months ago

I learned hugo recently and I was able to understand the directory structure and how to do stuff.

The tools that has are easy to use and are built-in features that I didn't found in Astro by lack of time to read its documentation or just me overcomplicating stuff.

I want to be able to have my theme separated from my content so I can re-use with other personal websites.

Ideally it would be nice if I can configure a default content folder and another one per branch name. Right now my setup in this repository allow me to have my main site in juanma.ar but my linktree kinda site in link.juanma.ar.

espinosajuanma commented 7 months ago

Mid-way through. I need to find a way to build different websites depending on the branch name, as I commented in the first issue.

If is not possible or takes a lot of effort, consider doing it differently.

espinosajuanma commented 7 months ago

As a comment, I am happy with the actual results of migrating to Hugo. It makes a lot of things easier and tidy.

espinosajuanma commented 7 months ago

I found the way to do it. I made a not-so-tidy way but I had to set up these files.

link.toml

baseURL = 'https://link.juanma.ar/'
languageCode = 'en'
title = 'Juanma Espinosa'

theme = 'juanma'

[params]
    author = 'Juan Manuel Espinosa'

I made the new layout in /layouts/link/links.html and then set a new folder for the content at the root level named link.

The netlify configuration is netlify.toml

[build]
    command = 'hugo'
    publish = 'public'

[build.environment]
    HUGO_VERSION = '0.122.0'

[context.link]
    command = 'hugo -c link --config link.toml'

So the way it works -c link is the content directory and --config is the specific new site configuration. Finally [context.{branchName}] is the keyword for building it differently from the main branch.

Btw, the link/_index.md has to be set either

type: 'links'
layout: 'links'

With all this setup I finished the migration to hugo to have a functional site again as it was with Atro.

I'll tidy my configuration files and content directories so I probably can improve and make the multiple branches websites better and more scalable.