Anchor Tags Not Working

If you’re creating a debugging post, please include the following info:

  1. Deployed on Huggingface Spaces
  2. If your app is deployed:
    b. Link: Test - a Hugging Face Space by victormiller
  3. Copy and pasted from here: streamlit/anchor_app.py at main · dataprofessor/streamlit · GitHub
    My repo: victormiller/test at main
  4. No error message. When you click on Section 1 or Section 2, you are not taken to that section.
  5. streamlit==1.38.0
    python:3.10

Hey @Victor6, so when I open the link with the hashtag included, e.g. https://huggingface.co/spaces/victormiller/test#section-2, it opens the website scrolled down to the section (or as far down as possible given the website height).
Am I understanding it correctly that you would like to see it scrolling down while being on the website and clicking on the anchor button?

Hey raethlein,

Yes, exactly. I’d like to use it as a way to navigate the page similar to a static table of contents. Is that possible?

Thanks,
Victor

Would the new st.navigation command help you? You could define each section as a page, which would show up on the sidebar and you also can access the page directly via a URL path.

I will give that a try - thanks!

1 Like