Answers.Body: <p>The setup you have there is creating routes within the system not overriding the URL property of your entry. If you just want to generate anchors you should uncheck "Entries in this section have their own URLs"</p>
  
  <p>Then within your template for your top-level structure item run a loop and output the content with ids and then the anchors as links.</p>
  
  <pre><code>{% set entries = craft.entries.section('myStructure') %}
  
  &lt;ul&gt;
  {% for entry in entries %}
      &lt;li&gt;&lt;a href="#{{ entry.slug }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;
  
  {% for entry in entries %}
  
      &lt;div id="{{ entry.slug }}"&gt;
          {{ entry.content }}
      &lt;/div&gt;
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-18T13:33:25.207Z
Answers.Text: Here's the problem: the 1st-level of the Structure *does* have its own URL, but the child structures do not, they just exist as anchored content within the 1st-level pages. Your solution eliminates those first-level pages, too. I still think the underlying issue here is simply that Craft doesn't know how to handle URLs with anchors in them, which should simply link to the referenced anchor's position on the linked page. There is no problem with the URLs being generated by my approach, just with the routing of those URLs. Linking to an anchor position on another page is a common practice.
Answers.UserDisplayName: cmal
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-18T16:14:56.890Z
Answers.Text: You can do it with the URL entries enabled as well. You just cannot call the `{{entry.url}}` parameter and accomplish What you're trying to do. The hash value is not passed to the server. So having a url like 'something#whatever' only passes in 'something' to the system to route the page. You can do what you're trying to accomplish, you just can't use the `{{entry.url}}` value. This issue on [answer](http://stackoverflow.com/a/3664324) may shed more light on how the browser interprets hashes.
Answers.UserDisplayName: Ian
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-18T19:27:35.220Z
Answers.Text: I'm curious if you've tried this. I'm creating the URL this way and the result is exactly the same as when using `{{ entry.url }}`: `<a href="/services/{{ entry.slug }}#{{ subEntry.slug }}">{{ subEntry.title }}</a>`
Answers.UserDisplayName: cmal
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-27T18:16:17.433Z
Answers.Text: The answer to this ended up having nothing to do with Craft. It was being caused by the Javascript routing used for the project. Sorry to waste everyone's time.
Answers.UserDisplayName: cmal
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T23:08:55.243Z
Answers.LastActivityDate: 2014-07-18T00:18:43.073Z
Answers.LastEditDate: 2014-07-18T00:18:43.073Z
Answers.UserDisplayName: Ian
Body: <p>I have a Structure setup where I'd like each child to link to an anchor within the parent page (see the attached image).</p>
  
  <p><img src="https://i.sstatic.net/TI2Tv.png" alt="enter image description here"></p>
  
  <p>But when I use <code>&lt;a href="{{ subEntry.url }}"&gt;</code> and click on the link, it redirects to the parent URL without the # anchor.</p>
  
  <p>e.g. <code>http://localhost:3000/services/web-interactive-design#website-design</code> redirects to <code>http://localhost:3000/services/website-design</code></p>
  
  <p>How can I prevent this from happening?</p>
  
Tags: <routing>
Title: Prevent Craft URLs containing # from redirecting
ThreadText: # Prevent Craft URLs containing # from redirecting
  
  (Asked by: username_0 on 2014-07-17)
  
  I have a Structure setup where I'd like each child to link to an anchor within the parent page (see the attached image).
  
  ![enter image description here](https://i.sstatic.net/TI2Tv.png)
  
  But when I use `<a href="{{ subEntry.url }}">` and click on the link, it redirects to the parent URL without the # anchor.
  
  e.g. `http://localhost:3000/services/web-interactive-design#website-design` redirects to `http://localhost:3000/services/website-design`
  
  How can I prevent this from happening?
  
  **Tags:** routing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-17. Score: 3
  
  The setup you have there is creating routes within the system not overriding the URL property of your entry. If you just want to generate anchors you should uncheck "Entries in this section have their own URLs"
  
  Then within your template for your top-level structure item run a loop and output the content with ids and then the anchors as links.
  
  ```
  {% set entries = craft.entries.section('myStructure') %}
  
  <ul>
  {% for entry in entries %}
      <li><a href="#{{ entry.slug }}">{{ entry.title }}</a></li>
  {% endfor %}
  </ul>
  
  {% for entry in entries %}
  
      <div id="{{ entry.slug }}">
          {{ entry.content }}
      </div>
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Here's the problem: the 1st-level of the Structure *does* have its own URL, but the child structures do not, they just exist as anchored content within the 1st-level pages. Your solution eliminates those first-level pages, too. I still think the underlying issue here is simply that Craft doesn't know how to handle URLs with anchors in them, which should simply link to the referenced anchor's position on the linked page. There is no problem with the URLs being generated by my approach, just with the routing of those URLs. Linking to an anchor position on another page is a common practice.  
  > **username_1**: You can do it with the URL entries enabled as well. You just cannot call the `{{entry.url}}` parameter and accomplish What you're trying to do. The hash value is not passed to the server. So having a url like 'something#whatever' only passes in 'something' to the system to route the page. You can do what you're trying to accomplish, you just can't use the `{{entry.url}}` value. This issue on [answer](http://stackoverflow.com/a/3664324) may shed more light on how the browser interprets hashes.  
  > **username_0**: I'm curious if you've tried this. I'm creating the URL this way and the result is exactly the same as when using `{{ entry.url }}`: `<a href="/services/{{ entry.slug }}#{{ subEntry.slug }}">{{ subEntry.title }}</a>`  
  > **username_0**: The answer to this ended up having nothing to do with Craft. It was being caused by the Javascript routing used for the project. Sorry to waste everyone's time.  
  
  ---
  
  