1

I have links on a page which go to pages_path('index'). That works fine, only I want each link to go to a specific section of a page.

So each link would look something like

www.example.com/pages/index#locations

Right now I'm using a rather hacky solution to generate this link

link_to "About", "#{page_path('index')}#about"

Is there a better way to achieve this?

Noah Koch
  • 831
  • 8
  • 10

1 Answers1

2

You just need to use the anchor option:

link_to "About", page_path('index', anchor: "about")
Chris Heald
  • 61,439
  • 10
  • 123
  • 137