Solved Any good getting started with Hugo resources
-
So I add the theme as a git submodule, and then in my site folder I override whatever by just copying what I need.
So if themes looks like this:
└── themes └── hugo-paper ├── i18n │ ├── en.yaml │ ├── ja.yaml │ ├── ko.yaml │ ├── ru.yaml │ └── zh.yaml ├── images │ ├── screenshot_dark.png │ ├── screenshot.png │ └── tn.png ├── layouts │ ├── 404.html │ ├── _default │ │ ├── list.html │ │ └── single.html │ └── partials │ ├── footer.html │ └── header.html ├── LICENSE ├── README.md ├── static │ ├── an-old-hope.min.css │ ├── apple-touch-icon.png │ ├── favicon.ico │ ├── highlight.min.js │ └── style.css └── theme.toml
And I want to add a custom CSS file, I'll copy the header.html file to
layouts/partials/header.html
in my site (you'll have to make the directories). Then I'll edit that file to add my custom CSS file, and I'll put my custom file instatic/custom.css
in the site directory. -
So what about this theme for a blog?
https://themes.gohugo.io//theme/hugo-tikva/post/ -
@stacksofplates so i have a clean set done locally.
Now I need to read through this
toml
file, basically copying it over top of the default one, and change things as needed.
-
@JaredBusch said in Any good getting started with Hugo resources:
@stacksofplates so i have a clean set done locally.
Now I need to read through this
toml
file, basically copying it over top of the default one, and change things as needed.
Yeah. So each theme is completely different because you can set up the site essentially however you want. The params enable/disable and modify different parts of the HTML that's generated. That's why if you just do
hugo new site
it's blank. There's no partials to create the site from. And theres also data files which help display different content types.I'll look over that theme and see what it looks like.
-
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally. -
@Obsolesce said in Any good getting started with Hugo resources:
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally.You need to paste up two levels. It's looking for the theme folder inside of the themes directory.
-
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally.You need to paste up two levels. It's looking for the theme folder inside of the themes directory.
I don't use that and only have one level up. That is the site. It's way easier.
-
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally.You need to paste up two levels. It's looking for the theme folder inside of the themes directory.
I don't use that and only have one level up. That is the site. It's way easier.
That may work, but you're not supposed to do it that way. From their documentation: https://gohugo.io/hugo-modules/theme-components/
The name used in the theme definition above must match a folder in /your-site/themes, e.g. /your-site/themes/my-shortcodes.
It's also much easier to segregate this way so you can use git submodules for the themes. You should have the theme as a submodule so you can pull in updates and keep that separate from your site versioning.
-
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally.You need to paste up two levels. It's looking for the theme folder inside of the themes directory.
I don't use that and only have one level up. That is the site. It's way easier.
That may work, but you're not supposed to do it that way. From their documentation: https://gohugo.io/hugo-modules/theme-components/
The name used in the theme definition above must match a folder in /your-site/themes, e.g. /your-site/themes/my-shortcodes.
It's also much easier to segregate this way so you can use git submodules for the themes. You should have the theme as a submodule so you can pull in updates and keep that separate from your site versioning.
That's always been a big PITA for me, so I purposely don't do it that way. It was confusing as hell to figure it out in the beginning, and their documentation didn't make any sense to me as a Hugo newbie, as it's not intuitive.
So what I did was download a theme, and use the theme itself as the base of the site. Whatever is in the
exampleSite
folder, I move it up one level, comment out the theme line in the config file, then generate the site from there.As for theme updates, all the good ones I've found and use haven't had any updates in YEARS and I seriously doubt there will be any more. So at least in my case, I was never worried about that. If there would be an update, it's small enough that it's no big deal to take care of it manually.
It was just simply too time consuming in the beginning, and the theming crap just wouldn't work for me. So how I got it working was a big time saver and, at least in my cases, there were absolutely no benefits to the theming junk.
If I ever find a decent theme that is kept updated, I'll think about doing it that way, but until then, I see no benefit. I get the site to exactly how I want it to be, keep it in GIT and push changes as needed and the site rebuilds and deploys to staging environment (public but my IPs only) automatically, and then to production (public) via approval gate.
-
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
You can get it going quick if you cut everything in the exampleSite directory and paste it up one level. Then comment out line number 5 in that config file you shown.
Then from that directory, enter
hugo serve -D
to test locally.You need to paste up two levels. It's looking for the theme folder inside of the themes directory.
I don't use that and only have one level up. That is the site. It's way easier.
That may work, but you're not supposed to do it that way. From their documentation: https://gohugo.io/hugo-modules/theme-components/
The name used in the theme definition above must match a folder in /your-site/themes, e.g. /your-site/themes/my-shortcodes.
It's also much easier to segregate this way so you can use git submodules for the themes. You should have the theme as a submodule so you can pull in updates and keep that separate from your site versioning.
That's always been a big PITA for me, so I purposely don't do it that way. It was confusing as hell to figure it out in the beginning, and their documentation didn't make any sense to me as a Hugo newbie, as it's not intuitive.
So what I did was download a theme, and use the theme itself as the base of the site. Whatever is in the
exampleSite
folder, I move it up one level, comment out the theme line in the config file, then generate the site from there.As for theme updates, all the good ones I've found and use haven't had any updates in YEARS and I seriously doubt there will be any more. So at least in my case, I was never worried about that. If there would be an update, it's small enough that it's no big deal to take care of it manually.
It was just simply too time consuming in the beginning, and the theming crap just wouldn't work for me. So how I got it working was a big time saver and, at least in my cases, there were absolutely no benefits to the theming junk.
If I ever find a decent theme that is kept updated, I'll think about doing it that way, but until then, I see no benefit. I get the site to exactly how I want it to be, keep it in GIT and push changes as needed and the site rebuilds and deploys to staging environment (public but my IPs only) automatically, and then to production (public) via approval gate.
Yeah that's more convoluted than following how they want you to do it.
Also about the theme updates.
As for theme updates, all the good ones I've found and use haven't had any updates in YEARS and I seriously doubt there will be any more.
That's 100% false. I know you're using meghna and it's had 22 commits this year the newest being 11 hours ago. Idk what you're looking at but it's not what you think.
Hugo is always evolving. I promise you if you don't keep your theme updated your site will break. Speaking from experience using it for a few years now.
-
@stacksofplates said in Any good getting started with Hugo resources:
That's 100% false. I know you're using meghna and it's had 22 commits this year the newest being 11 hours ago. Idk what you're looking at but it's not what you think.
That's old, I don't use that anymore even though it's still running.
-
How they want you to do it works like this:
mkdir -p mysite/themes
git clone theme into themes
cp -R themes/theme/examplesite/* .
#3 is obv assuming you're in the site directory. You're done. Now just edit your config.
You can also do
hugo new site
and it gives you a directory structure but if you're using the themes example folder it's not really needed. -
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
That's 100% false. I know you're using meghna and it's had 22 commits this year the newest being 11 hours ago. Idk what you're looking at but it's not what you think.
That's old, I don't use that anymore even though it's still running.
The Hugo themes list is default sorted by last updated. I had to scroll down 151 themes before I found one that wasn't updated in 2020 and the next was December 30 or 31. The themes are constantly updated.
Sure you can find one that someone let die, but you can do that with anything.
-
Oh man i was looking at the wrong shit. There are active updates to it, like you said.
I'll give that a go, then, as now it looks beneficial. But looking at it, it seems as if updates to the theme will break things.
I'm not convinced of the theme update process. If I have modified files in a higher directory, the updates won't apply? How does that work?
-
@Obsolesce said in Any good getting started with Hugo resources:
Oh man i was looking at the wrong shit. There are active updates to it, like you said.
I'll give that a go, then, as now it looks beneficial. But looking at it, it seems as if updates to the theme will break things.
I'm not convinced of the theme update process. If I have modified files in a higher directory, the updates won't apply? How does that work?
No you would have to change those since they are custom.
There only way to not update the themes is to never update Hugo. Theyveade templating changes in the past and the themes have to follow that.
-
@stacksofplates said in Any good getting started with Hugo resources:
How they want you to do it works like this:
mkdir -p mysite/themes
git clone theme into themes
cp -R themes/theme/examplesite/* .
#3 is obv assuming you're in the site directory. You're done. Now just edit your config.
You can also do
hugo new site
and it gives you a directory structure but if you're using the themes example folder it's not really needed.Yes, that worked. Thanks! Up and running "proprly" now.
Could you explain how the theme updates work then? So whenever there's a theme update to, for example, config.toml, my site isn't going to use the new one since it's copied above, same with other files... Do I have to manually updated this stuff after finding out somehow there was an update?
-
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
How they want you to do it works like this:
mkdir -p mysite/themes
git clone theme into themes
cp -R themes/theme/examplesite/* .
#3 is obv assuming you're in the site directory. You're done. Now just edit your config.
You can also do
hugo new site
and it gives you a directory structure but if you're using the themes example folder it's not really needed.Yes, that worked. Thanks! Up and running "proprly" now.
Could you explain how the theme updates work then? So whenever there's a theme update to, for example, config.toml, my site isn't going to use the new one since it's copied above, same with other files... Do I have to manually updated this stuff after finding out somehow there was an update?
No the override fills always override. It's just any Hugo specific changed would need to be added.
-
@stacksofplates said in Any good getting started with Hugo resources:
@Obsolesce said in Any good getting started with Hugo resources:
@stacksofplates said in Any good getting started with Hugo resources:
How they want you to do it works like this:
mkdir -p mysite/themes
git clone theme into themes
cp -R themes/theme/examplesite/* .
#3 is obv assuming you're in the site directory. You're done. Now just edit your config.
You can also do
hugo new site
and it gives you a directory structure but if you're using the themes example folder it's not really needed.Yes, that worked. Thanks! Up and running "proprly" now.
Could you explain how the theme updates work then? So whenever there's a theme update to, for example, config.toml, my site isn't going to use the new one since it's copied above, same with other files... Do I have to manually updated this stuff after finding out somehow there was an update?
No the override fills always override. It's just any Hugo specific changed would need to be added.
I see. Still better than not at all. So I'll take it.
Anyways, need to make the changes to other sites. Luckily it's all simply laid out and only takes a minute.
-
I haven't had a theme that broke from something like the config.toml or a css change. It's more things like this: https://gohugo.io/news/0.57.2-relnotes/
So I think if I remember right that .Pages gave you everything if you were on the home page. They changed that to only immediate children and .Site.Pages now gives you everything.
I had that break a theme. But updating the theme fixed it and I didn't have to touch any of my override files.
So it's really only if you are extensively modifying the theme at those kind of levels. And you'd see it break if you are using the dev server when you do your local work.
-
I'm having trouble with overriding css. Maybe I'm doing it wrong.
I know I read somewhere on creating a customcss file, but I've been through so many themes I have no idea if that's in general or theme specific.
What I tried that doesn't work is creating a new structure top level -- assets\css\style.css