Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop large anchor ID's #167

Closed
Naatan opened this issue Aug 14, 2015 · 5 comments
Closed

Crop large anchor ID's #167

Naatan opened this issue Aug 14, 2015 · 5 comments

Comments

@Naatan
Copy link

Naatan commented Aug 14, 2015

This is an example of a generated anchor ID on the wiki I'm working on:

Manual/prefs#preferences_editor-preferences_smart-editing_configuring-word-or-character-wrap

It's veeery long, too long. Could this be handled more intelligently? eg. it seems to be including all parent headers in the anchor, this seems unnecessary. Additionally it would be nice if we could force a max length for these anchors, and have it crop if the max length is reached.

I understand the main reason for this is to ensure the anchor is unique, but you could also generate a hash based on the current information used and append this.

Far as I'm aware these hashes don't affect SEO, so there should be no concerns there.

@dometto
Copy link
Member

dometto commented Aug 14, 2015

I understand the main reason for this is to ensure the anchor is unique, but you could also generate a hash based on the current information used and append this.

That would make it more difficult for a human to link to a section though...

@Naatan
Copy link
Author

Naatan commented Aug 14, 2015

I'm not saying the hash becomes the anchor. I'm saying the anchor is the name of the header (just the one its linking to, not its parents) and a hash is appended to ensure it's unique.

@dometto
Copy link
Member

dometto commented Apr 30, 2017

It appears github just uses the title of the (sub)heading and appends an index to it when there are possible conflicts. For instance, if there are two sections called use-spaces-in-filenames the generated anchors will be:

  • #use-spaces-in-filenames
  • #use-space-in-filesnames-1

Does that seem like a reasonable approach?

@dometto
Copy link
Member

dometto commented Feb 5, 2018

Also see gollum/gollum#1261

dometto added a commit that referenced this issue Nov 18, 2018
Do not include ancestry in anchors. Resolves #167
@dometto
Copy link
Member

dometto commented Nov 18, 2018

Fixed in 5.x (see here)

@dometto dometto closed this as completed Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants