Bringing in menu and social media links through config.toml or json data?

Hello, what is the recommended way to bring in menu items and social menu items in the theme?
For menus, I used to define something like this in config.toml

# Menus
[[menu.nav]]
  name    = "Home"
  url     = "/"
  weight  = 1

[[menu.nav]]
  name    = "About Us"
  url     = "/about"
  weight  = 2

 ...

and the following for social media

[[params.social]]
  icon  = "icon-facebook"
  title = "Connect with me on Facebook"
  url   = "https://www.facebook.com/xyz"

[[params.social]]
  icon  = "icon-twitter"
  title = "Follow me on Twitter"
  url   = "https://twitter.com/xyz"

However I noticed in the “Build Websites with Hugo” book by Brian P Hogan, the author creates a JSON file in the data folder like so:

{
  "accounts": [
    {
      "name": "Twitter",
      "url": "https://twitter.com/xyz"
    },
    {
      "name": "Facebook",
      "url": "https://facebook.com/xyz"
    }
  ]
}

Then he uses that to bring in the data. The JSON way is also how it is done in Gatsby, at least what I seen in a course.

I was wondering what is your opinion on these. Which method would be more ideal and if there is a dissadvantage of using one over the other.

Better to specify the Menu configuration in the project config, unless you plan to update the menu dynamically, in which case it might make sense to keep it as a JSON under the dataDir.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.