5

Note: This question could possibly fit as a question on a main site somewhere, whether stack overflow, user experience or somewhere else. I'm asking it here because: (a) I don't know where else it would fit, and (b) The primary reason I want to know is to improve my answering abilities on this site.

Linking to man pages

I already have a favored method for this, which you can read about in the less man page in two places:

LESS='+/\+cmd' man less

and

LESS='+/LESS[[:space:]]*Options' man less

(See what I did there?)

Linking to websites

The easy

Some websites, such as the wooledge Bash guide, have little "table of contents" at the top which allows you to easily link to a very specific part of the page:

The moderate

Other pages such as the POSIX specifications don't have such an easy interface for linking, but it is still possible:

Notice that the tag name at the end of the URL is much less human-readable on the POSIX site than the tags in the Bash guide:

http://....#Aliases
vs.
http://....#tag_18_09_02

The difficult

Other websites contain info that I would like to be able to link to directly, but it may be buried far down on the page with no obvious way to link directly to it. For instance, The Art of Unix Programming is full of excellent material, but I don't know of any way to link with any finer granularity than a whole page:


  1. Is there a way to construct a link with a tag that will take users to an arbitrarily specific point on the page?

  2. If not, how can I see what tags have been included by the creator of the website so that I can link directly to a specific point on the page?

  • The SPOT Rule. I don't know of a better option than RTFS, though. – Michael Homer Apr 2 '16 at 0:36
  • I've never worked much with HTML, myself. I guess it's the "id" attribute, though? Thanks, that helps! – Wildcard Apr 2 '16 at 0:46
  • 2
    @Wildcard id or name attributes, iirc. – muru Apr 2 '16 at 8:17
  • Related reading: askubuntu.com/a/510989/457111 – Wildcard Jul 12 at 21:36
6

The type of links you are referring to are constructed using the name attribute to the HTML <a> tag. The general idea is that you set an anchor like this:

<a name="foo"></a>

You can then link to that part of the page by linking to the anchor:

<a href="#foo">link to foo</a>

The only way of knowing whether a particular page's author has chosen to include such anchors is to look at the page's source.

So, no there is no way of creating such a link if it is not already present in the webpage you want to link to and the only way you can find out if it is is to search for something like "# in the page's source.

2

If the website developer added someway to hook into a specific element or section of a webpage then you could use the id or name attributes of those HTML elements as previously mentioned.
If the developer provided no such mechanism, there is a service http://citebite.com/ which allows you to create a link which takes the person clicking the link to a specific section of text within a page.
Here is a link created with citebite.com which takes you to a specific section within a page from the art of Unix programming website.
The only downside is its not the real website, it seems - in order to generate the hook - they need to recreate the webpage, but any links within this cloned webpage take you back to the original site.

  • Interesting info, thanks. – Wildcard Apr 19 '16 at 7:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .