cancel
Showing results for 
Search instead for 
Did you mean: 
koger_13
Community Member

Links to headers within pages

Jump to solution

Can you create links to subheaders of sections down the page at the top that will allow users to jump via link? I'm working on a page that will be a long directory list, and we do not want to use accordions. This type of page may be developed for other uses and has the potential to become unwieldy. I.e. users would have to scroll a while just to know about subcategories and info below. Accordions would shortcut this but are not preferred departmentally. I've poked in the style guide and can't find this, though I thought it existed somewhere. Can I list the categories at the top of the page with a "Jump to" function and link them to those subheaders down the page?

15 Replies

I just read this article : https://community.canvaslms.com/groups/higher-ed/blog/2017/01/22/anchor-tags-explained-by-a-language... 

James Jones's post about the order of loading in a page might be the issue I have with the anchors.

 @frederik_vangom ,

That James Jones guy is all over the place. As a follow-up to that other message, it seems that there was some kind of bug in Chrome that was causing links not work, so it may not have been the order the page is loaded. When I wrote that, Canvas had recently switched from delivering the content as part of the page to delivering the content within a JavaScript variable and then displaying it on the page and that was causing problems for other things. Now Google turns up plenty of hits when asking about links in Chrome and most of them refer to a bug in Chrome.

I just recreated the experiment that I ran back then, or close to it. 20 paragraphs of Lorem Ipsum, headings with anchor elements with id=p1, p2, p3, ... every 2 paragraphs. Another page in Canvas with links to each of those anchor elements. They all worked fine in Canvas whether I opened it in a new tab or just followed the link in the current tab.

I'm beginning to think it was a bug with Chrome around that time, but I still think that if your pages are so long you need anchors, you might want to think about chunking them up. That's part of the recommendation for developing courses: Course Evaluation Checklist 

Hi James,

Thanks for the reply and the testing. Too bad if it would be a bug .. I have quite long pages because I need to add a lot of images (software application screenshots). The actual text content is not that long. 

When I click the link (that refers to an anchor on another page) I also get some strange behaviour; it opens the other page, and starts scrolling down, but at some point it stops scrolling and starts scrolling back up and stops again, at the wrong place (not an anchor). This  happens in the Google Chrome browser. Haven't tested other browsers.

With the linking to anchors on other plages I also wanted to create an index page that I can design myself.

I seem to have found a solution for the problem. I came upon this website : HTML Tags/Link Tags/links to a named anchor - TAG index 

An anchor can also be created with the name attribute instead of the id attribute and this seem to work at the moment for me. When clicking the link to an anchor on another page it opens this page and jumps directly to the anchor (created with the name attribute) without even showing scrolling.

Thanks for sharing your findings about anchor links to another page in Canvas. 

This solution however seems to require the use hard links (url#id) instead of relative links (#id). As a result, do the anchor links still work when you copy the Canvas course site for a new semester?

frederik_vangom
Surveyor II

If you import an old course (or parts of an old course) to a new course with the import options in the course Settings page, this is possible. I had to do this myself. All the links to Canvas pages and Canvas files are updatedn, I guess only if also all pages and files are imported.

What doesn't seem to work is when you export an old course to a compressed file and try to import this compressed file. All links are kept the same, so all id references are not updated and since a course also has it's unique id number, none of the file or page links are found.