title: Page Anchors In Yesod
body: <p>Normally you can specify an anchor on a page such as "index.html" with code such as:</p>
  
  <pre><code>&lt;a href="#anchor"&gt;Link Text&lt;/a&gt;
  </code></pre>
  
  <p>You can then jump to that anchor when the page is displayed by including it in the path:</p>
  
  <pre><code>http://example.com/index.html#anchor
  </code></pre>
  
  <p>I am developing a landing page with the Yesod Haskell framework, and would like to integrate this functionality into my landing page.</p>
  
  <p>Currently I have a navigation bar with several links at the top of the page. The navbar is specified with hamlet as:</p>
  
  <pre><code>&lt;div #navbar .collapse.navbar-collapse&gt;
      &lt;ul .nav.navbar-nav&gt;
          &lt;li :Just HomeR == mcurrentRoute:.active&gt;
              &lt;a href=@{HomeR}&gt;_{MsgHome}
  </code></pre>
  
  <p>Note that the href is specified with "HomeR". "HomeR" is defined in the Yesode "config/routes" file that lists all of the paths for the site.
  It looks like:</p>
  
  <pre><code>/ HomeR GET
  /settings SettingsR GET
  </code></pre>
  
  <p>Here is my problem. I can add an anchor to a section of the hamlet specification, then modify the href on the title bar to jump to that section such as:</p>
  
  <pre><code>&lt;li :Just HomeR == mcurrentRoute:.active&gt;
      &lt;a href=@{HomeR}#section0&gt;_{MsgHome}
  </code></pre>
  
  <p>However this is annoying for several reasons. First the anchor is not checked for validity at compile time like the other paths. </p>
  
  <p>Second normally the current page is highlighted on the navigation bar with the code: </p>
  
  <pre><code>&lt;li :Just HomeR == mcurrentRoute:.active&gt;
  </code></pre>
  
  <p>With this approach I can highlight for individual pages, but not individual anchors within a page.</p>
  
  <p>Is there a way to insert safe anchors into the Yesod config/routes file. Or is it only possible to have a route with actual pages. This would allow jumping to sections of the page in the navbar, then highlighting the section that was clicked on. If this is not possible is there a better way to deal with page anchors in yesod?</p>