asurcodes/amperage

Menu adds up urls and therefore create fals paths

sjs-sudo opened this issue · 6 comments

Hi!

Thank you for creating this beautiful theme first of all!

I am new to using Hugo and I ran into trouble with the menu bar. As soon as I click on one of the menu sections I am stuck in this location. From there on every further click just adds to the URL, e.g. www.name.com/about --> www.name.com/about/cv instead of www.name.com/cv
How do I set the menu to access the actual url instead of adding on top? I did not set urls inside the .md files, only in the config.toml in the menu section. I also did not change or add partial.

I would be very grateful if you can help me solve this problem. I was unable to locate a solution.

Best,
J

Hello @sjs-sudo, thank you for the kind words!

I would need to take a look at your code, for now I can provide you with a example from my own blog:

[[languages.es.menu.main]]
    identifier = "twitter"
    name = "Twitter"
    url = "https://twitter.com/asurbernardo"
    weight = 5
[[languages.es.menu.main]]
    identifier = "github"
    name = "GitHub"
    url = "https://github.com/asurbernardo"
    weight = 10
[[languages.es.menu.main]]
    url = "/uses"
    name = "Mis /uses"
    weight = 15
[[languages.es.menu.main]]
    url = "/support"
    name = "Apóyame"
    weight = 20

[[languages.en.menu.main]]
    identifier = "twitter"
    name = "Twitter"
    url = "https://twitter.com/asurbernardo"
    weight = 5
[[languages.en.menu.main]]
    identifier = "github"
    name = "GitHub"
    url = "https://github.com/asurbernardo"
    weight = 10
[[languages.en.menu.main]]
    url = "/en/support"
    name = "Support me"
    weight = 15

You may be missing the / at the beginning of your URL so Hugo is creating nested relative URLs instead?

Hi!

thank you for your super fast reply.
my code is public on github: https://github.com/sjs-sudo/PortfolioWebsite

I have the / so this cannot be the reason. but maybe I am not using the language menu correctly?
You can also check the website here: jasmin-schaedler.com

Thank you,
J

Yes, your configuration is wrong, you have to be really careful with formats like toml or yaml since they rely on tabs for hierarchy.

You should be able to fix it by removing the extra tab on your menu entries in your configuration file:

Before

    [[languages.en.menu.main]]
        identifier = "home"
        name = "HOME"
        url = "/"
        weight = 1

After:

[[languages.en.menu.main]]
    identifier = "home"
    name = "HOME"
    url = "/"
    weight = 1

This has nothing to do with the theme itself, I would recommend you to read the toml specification, it might come useful if you are thinking about using Hugo.

Hope you get it up and running.

Asur

Thank you for your advice. Unfortunately it did not fix the issue. I also compared all the other syntax with your config file and nothing seems to be wrong. And I also deleted all the layout files apart from the logo from my folder to be certain it only uses the theme partials. It did not help either.
When I run the page on local 1313 this problem does not occur and never did. However, there it always opens a new tab when I click a menu category.

Do you have any further ideas what the problem could be?

I just noticed you are missing the baseUrl parameter in your config. I'm pretty sure Hugo uses that to calculate URLs... 🤔

EDIT

BTW, I didn't link it before but my blog is public aswell, feel free to use the configuration and content structure: https://github.com/asurbernardo/blog/blob/master/config.toml. Just be careful, there are things ment for the develop branch that I will be releasing soon like the search box...

ah this is really crazy, I had added the URL before and it messed it up even more. But now that the formatting of the menu is correct it is working. Thank you for your patients :)

Now my next task will be to figure out _index.md files to add content to the homepage instead of posts :)