Answers.Body: <p>It depends on what you mean by "get" the hash anchor, but I'm assuming you're trying to get it in either PHP, Twig, or JavaScript.</p>
  
  <p>It is physically impossible to get the <code>#anchor</code> part via PHP, since PHP never has access to that information. <a href="https://stackoverflow.com/a/2317523/3467557">This SO thread</a> describes the issue.</p>
  
  <p>If you're trying to access the <code>#anchor</code> in Twig, you're probably out of luck there too. Twig is just a PHP parser, so you've essentially got the same problem.</p>
  
  <p>All you can do is access it via JavaScript. In which case, there is nothing Craft-specific about it (see linked SO thread).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-07T05:28:19.727Z
Answers.LastActivityDate: 2020-02-07T05:28:19.727Z
Answers.UserDisplayName: Lindsey D
Body: <p>I am using an entry's slug as the anchor for a page. </p>
  
  <p>How do I grab the anchor from the request?
  For example I want to get <code>#article-one</code> from <code>/blog/#article-one</code></p>
  
  <p>If it's not possible, is there a way to grab the full URI <code>/blog/#article-one</code> including the hash?</p>
  
Tags: <craft3><url>
Title: How to get the hash/anchor in the URL?
ThreadText: # How to get the hash/anchor in the URL?
  
  (Asked by: username_0 on 2020-02-07)
  
  I am using an entry's slug as the anchor for a page.
  
  How do I grab the anchor from the request?
  For example I want to get `#article-one` from `/blog/#article-one`
  
  If it's not possible, is there a way to grab the full URI `/blog/#article-one` including the hash?
  
  **Tags:** craft3, url
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-07. Score: 3
  
  It depends on what you mean by "get" the hash anchor, but I'm assuming you're trying to get it in either PHP, Twig, or JavaScript.
  
  It is physically impossible to get the `#anchor` part via PHP, since PHP never has access to that information. [This SO thread](https://stackoverflow.com/a/2317523/3467557) describes the issue.
  
  If you're trying to access the `#anchor` in Twig, you're probably out of luck there too. Twig is just a PHP parser, so you've essentially got the same problem.
  
  All you can do is access it via JavaScript. In which case, there is nothing Craft-specific about it (see linked SO thread).
  
  
  ---
  
  