Giter VIP home page Giter VIP logo

Comments (8)

hossainemruz avatar hossainemruz commented on September 28, 2024

Hi @SrNetoChan! Thank you for bringing this up. Currently, there is no guide for upgrading from v3 to v4. I will try to write one as soon as possible.

from toha.

SrNetoChan avatar SrNetoChan commented on September 28, 2024

Let me know if I can help somehow. Comparing the demo site older version with the new one might help understand what changes need to be done, right?

from toha.

hossainemruz avatar hossainemruz commented on September 28, 2024

This should be easy few steps:

  1. Delete the submodule
  2. Update the config.yaml file to be similar to this.
  3. Follow the quickstart guide to run updated theme.

You shouldn't require any change in data and content folders.

from toha.

SrNetoChan avatar SrNetoChan commented on September 28, 2024

In that case, I will try make it work and write down the process, in case you want to use it for docs

from toha.

hossainemruz avatar hossainemruz commented on September 28, 2024

That would be great! Thank you.

from toha.

SrNetoChan avatar SrNetoChan commented on September 28, 2024

So, I have successefuly updated my site following your instruction. This are the note I took for doing it

Migration from V3 to v4.0 Toha Theme

1 - Remove toha theme submodule

The theme no longer uses a git submodule to be installed, therefore, we start by removing the toha theme submodule

git rm themes/toha/
git commit -m "Remove v3 theme"

2. Meet the requirements

For building the site locally we will need to update/install the following requirements:

Hugo version v0.118.x (extended) or later.
Go language version v1.18.x or later.
Node version v18.x and npm version 8.x or later.

3. Add missing files

The new theme needs a couple of new files

From the https://github.com/hugo-toha/hugo-toha.github.io sample site I have copied the following files

  • LICENSE - (optional) This changes the license from GNU to MIT
  • go.mod
  • go.sum

Edited the go.mod file and changed the first line to point to your site repository

module github.com/<your username>/<my site repo name>

4. Update the config.yaml file

There were some changes in the way the config.yaml file needs to be written.

First, we need to replace the theme option by the module option, so remove this line

theme: "toha"

And add the following lines

# Use Hugo modules to add theme
module:
  imports:
  - path: github.com/hugo-toha/toha/v4
  mounts:
  - source: static/files
    target: static/files
  - source: ./node_modules/flag-icon-css/flags
    target: static/flags
  - source: ./node_modules/@fontsource/mulish/files
    target: static/files
  - source: ./node_modules/katex/dist/fonts
    target: static/fonts

Update the darkMode options, which is now under features. Remove this lines

 darkMode:
    provider: darkreader
    enable: true
    default: system

And add this under features: :

  features:

    # Enable dark theme
    darkMode:
      enable: true

A few sections we missing an extra option called services. the changes were in comment, analytics and support:

Comment

    comment:
      enable: false
      services:
        disqus:
...

Analytics

# Enable Analytics
analytics:
  enabled: true
 services:

...

Support

   # Enable Support
    support:
      enable: true
     services:
...

Some other options have changed 

`enableTOC: true` was replaced by

toc:
enable: true


`enableTags: true` was replaced by

tags:
enable: true
on_card: true # enables tags in post cards


`showFlags: true` as replaced by

flags:
enable: true
# # If you want to use different country flag for a language, specify them here.
# flagOverwrites:
# - languageCode: en
# countryCode: us


## 5. Built the site

Building the site now requires a few more steps. At least for the first time you do it.

1. Load Hugo modules

hugo mod tidy

2. Install node modules

hugo mod npm pack
npm install
`

(This last command a few more files that I also added to the repo for caution. Not sure it needed or not.)

package-lock.json
package.hugo.json
package.json

I did not commit the /node_modules folder and actually added it to the .gitignore file

  1. Build the site

hugo server -w

Update github workflows

My site was using a github workflow/action to deploy the site on each commit. I add to replace it by the one provided in the https://github.com/hugo-toha/hugo-toha.github.io, the merge/to/main.yml, because it deals with the loading of hugo modules and install node modules.

from toha.

eishundo avatar eishundo commented on September 28, 2024

Thanks @SrNetoChan. I had gone through the upgrade myself before I saw your notes. I had missed the "services" changes so glad I read through your guide.

Regarding:

analytics:
  enabled: true

I have changed my config to:

analytics:
  enable: true

The template works with both, but most of the other items appear to use "enable" rather than "enabled", so I updated for consistency.

Also see #856 if you are using a newer version of Hugo with GoogleAnalytics.

Question: What have you done with "assets/jsconfig.json"? I see this is in the repository for the example site (https://github.com/hugo-toha/hugo-toha.github.io/blob/main/assets/jsconfig.json), but can/should we add this to .gitignore?

from toha.

hossainemruz avatar hossainemruz commented on September 28, 2024

Question: What have you done with "assets/jsconfig.json"? I see this is in the repository for the example site (https://github.com/hugo-toha/hugo-toha.github.io/blob/main/assets/jsconfig.json), but can/should we add this to .gitignore?

I think it gets added automatically by the build process. You should be able to ignore that.

from toha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.