How is the main menu (hamburger) link/panel generated?

Excuse my lack of expertise on the topic but how does Discourse handle the clicking of the hamburger menu link?

Context: I’m using the prerender.io service to serve an HTML version of the main (JS version of the site)

The menu hamburger link doesn’t work.

You can test ( the site ) by using the chrome dev tools and changing the agent to Googlebot smartphone. When using the googlebot user agent you’re in effect getting the HTML prerender version.

Side Note: According to this blog post from prerender , it could have issues with code like

`<a onclick=”goTo(‘page’)”>Anchor</a>`
`<a href=”javascript:goTo(‘page’)”>Anchor</a>`
`<span onclick=”goTo(‘page’)”>Anchor</span>`

All links need to be between tags and define a target URL within the href attribute for Google to be able to find and follow it.

Perhaps the main menu link is generated using this method?

Any ideas on a solution would be very much appreciated.

Edit I took the site off prerender for now ( but keeping JS version served to bots ) - Surprisingly google bot seems to render it correctly once in a while. I also have no menu issues when using the google bot as the user agent in chrome. Im going to test this for a little bit.

My apologies here, I made a simple question quite confusing …

The links within the menu seem fine, my issue is just the actual hamburger link itself - when rendered with prerender it just won’t open.

This post by @Johani was super helpful in trying to diagnose

Am I on the right track looking at this bit of code ( as far as the functionality for when you click the hamburger menu )

The menu is appended to the document with Javascript when the button is clicked, so it won’t easily be converted to work on an HTML-only version of the site.

Here’s where the button is added, you can see it has an action named toggleHamburger:

The toggleHamburger action is defined later in the same file, here:

toggleHamburger changes the hamburgerVisible state, so the menu is ultimately added with panels.push(this.attach("hamburger-menu")); which you can see here:

1 Like

Quality response @awesomerobot , I’m sure the community appreciates it.

I will look this over to see if custom work is worth it.

The response I got from prerender.io was basically if it uses “complicated JS” it probably wont work. Not sure how well they studied the situation though.

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