-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IDEA] Testing Hugo Modules (as a PoC) #165
Comments
For reference see: #158 |
This is the way the Hugo Project itself integrates Bootstrap: https://github.com/gohugoio/hugo-mod-bootstrap-scss/tree/main it includes a sample site. |
Fork for the PoC: https://github.com/mnordhaus/adritian-free-hugo-theme |
We can use the demo repo (https://github.com/zetxek/adritian-demo) as a testing ground for the PoC, once there's some changes. This could very much be a new branch/tag, either V1.5, or 2.0- that way we can test the integration before releasing. |
The v2.x relese tag will be a great idea, because i think this changes will require a little work :P |
@dcorto @mnordhaus I've gone ahead and created a new branch (https://github.com/zetxek/adritian-free-hugo-theme/tree/2.x-hugo-modules), and invited you as collaborators - so we can build it in the same branch (instead of having to make a big PR once the change is done, we can iterate in smaller PRs in this repo directly :-)) |
@zetxek 🔝 |
Thank you @zetxek I assume tho that we need a fork to test this feature in general. But for the detail work a branch is the best way IMHO too. |
I have forked the demo-repository already and hope to find some time to make the first break through this week. |
Why would we need a fork? 🤔 - if all the changes can be made from a separate branch (if I get the idea right). For now, I've done a couple of things (as very basic starters). In this repo:
In the demo repo (https://github.com/zetxek/adritian-demo)
My idea is to setup a demo that imports the theme as module - and then take it from there (ie: if there are errors, handling them, etc) |
I doubt that we can use releases with a branch: https://gohugo.io/hugo-modules/use-modules/#get-a-specific-version
|
I also think we can't also use branches - but tags should be ok :) https://discourse.gohugo.io/t/how-to-add-a-theme-using-modules-for-beginners/20665/4 (that's why I created the tag too, I don't think the branch would suffice) The idea with the tag is to have a future release tag ( |
Oh - it seems that branches would also be ok; just not in the https://discourse.gohugo.io/t/specify-branch-with-modules/23977/4
|
For the proof of concept, I've tried via a tag and that didn't work. Via commit hash it did (but it picked the wrong version/tag 🤔 - it got the unpublished version as
|
As first step, I've been able to render something localy - although in the vercel preview it fails: Now I got to a "theme" error :)
It seems to come from
So maybe the next step is to actually import bootstrap as a module too? |
Something that can be useful @mnordhaus @dcorto.
gives the same "experience" as if the theme was imported - as it gives me me the same error as the demoSite:
It seems that the fix/change needed now is about being able to import bootstrap in the scss. |
@zetxek that error is because in the file there is twice the "min_version" key defined :) Lines 10 and 21 of the file. And i don't have idea about the scss error at this moment :( I'm looking along the day if i found something ;) |
True! Fixed in a1b40fd, one error down! 👨🦯
I think that it's related with how the assets are mounted. What this module does is that it exposes the (non-hugo-module) bootstrap repo, as mounted in https://github.com/gohugoio/hugo-mod-bootstrap-scss/blob/main/go.mod#L7 Given that - the import should be https://github.com/gohugoio/hugo-mod-bootstrap-scss/blob/main/exampleSite/assets/scss/styles.scss Now, the import I'm trying to make is not working, neither with 🤿 At least that's my last thought, let's see if with some diving I can do now I can figure something! (metaphor inspired for sure by my holiday status 😆) |
It doesn't look like progress... ![]() But I think it's a bit of it.
Basically: the theme renders now. But the sass file is not processed - therefore, there's no styling at all. |
Huge step forward! 👏 |
Eureka! 🍎 ![]() I have looked at the config of one of the themes recommended by @mnordhaus: And in dff5732 made a change that:
Note that the codebase of bootstrap is fully deleted from the theme - so it's completely modularized. |
Bravo @zetxek and @mnordhaus 👏 |
Wow! If tickets assigned to me would solve itself like that on my job ... huge thanks for pushing this forward so quickly. I had a lot on my desk the last few days and got sick on top of it. I promise to read through all the post and I have seen the Pull Request already and give my thoughts to tomorrow. |
So I am also all in for keeping Bootstrap within the theme for now for two reasons. First rather do one step at a time and second but more importantly I feel that there is also room for improvement on how Bootstrap is integrated in general. I'll dive into that separately. I agree also on using modules for extensions like search etc. (I like to add a search to my site eventually). Modules seem to have some advantages over git-submodules tho:
In general I think we need to view this issue from three angles
A user is here a technical minded but likes to have an easy start. However Modules could allow adding things like Decap CMS or Sveltia CMS in the future.
Keep the theme Maintainable and easy to understand. Splitt the theme into to many (dependent) Modules might make the code unreadable or -> over engineered. While having a large Monolit is also a problem. The Them should not have a too big of a footprint and also it should be possible to develop add ons separately from a core.
Once a website gets larger build time is a concern not only because it will cost money eventually - especially when you like to deploy often. I am not sure which has here advantages. I suggest to release the current status and use this issue to learn a bit more about modules. I like to start with my website and use this theme finally and will report here about what I learned. Thank you again for all the efforts! |
This is the way how the Bootstrap dudes work within there Blog (also Hugo as the documentation too): https://github.com/twbs/blog/blob/main/package.json https://github.com/twbs/blog/tree/main/src/assets/scss |
As mentioned in #166 (comment) - let's explore bootstrap integration improvements, aside of the 2.0.0 release itself (that has added support for hugo modules). Shall we consider this PoC (hugo modules) fixed by #166, and divide further improvements in other issues? (btw for the submodule integration I've made a clone of https://github.com/zetxek/adritian-demo, https://github.com/zetxek/adritian-git-submodule-demo), just to automate checks and make sure that external integration via git is not broken (as the focus will be in the hugo module now). |
From my point of view this ticket is completed and I agree we should discuss the other issues in separate ones. |
Hugo Modules (https://gohugo.io/hugo-modules/) allow to manage project dependencies in a lightweight way. Such that the Theme can be loaded as a dependency instead of checking it out and copying it into a themes folder. Furthermore Hugo Modules allow to divide the theme itself into Components.
For example the Bootstrap code could go into a separate module or extensions to the theme could be provided in manageable way.
Through a thoroughly thought through concept Hugo Modules would provide better maintainability through the divide and conquer principle. Also integrating the theme as a Hugo Module solves licensing issues. Especially when the content should be provided under a different license then MIT (e.g. Creative Commons)
As a first step I suggest to provide a small showcase or proof of concept. Using the theme as a Module and also externalize the Bootstrap dependencies into a separate Module
Alternatively Git-Submodules are providing similar capabilities. Also using build tool and a package manager like Webpack or npm is an option. But Hugo Modules are built in and work without any other dependencies.
However the PoC should also show that utilizing Hugo Modules would not block other alternatives.
Questions the PoC should answer:
After that this ticket should be a foundation on how to go forward with Hugo Modules
@zetxek If you like you may assign this ticket to me.
The text was updated successfully, but these errors were encountered: