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

Allow flag for natural table of content anchor texts #387

Closed
matsko opened this issue Aug 5, 2014 · 12 comments
Closed

Allow flag for natural table of content anchor texts #387

matsko opened this issue Aug 5, 2014 · 12 comments

Comments

@matsko
Copy link

matsko commented Aug 5, 2014

I'm in the process of switching my blog over to Hugo from Jekyll and one of features that my current website has is my own, custom table of contents. But now since I'm using Hugo, I can simply use the {{ .TableOfContents }} markdown template function. It works great, but I feel that the generated "#toc_X" anchor tags are not good for SEO (especially for articles that had different tags from before).

What would be really nice is to have the anchor URLs be generated as a lowercase, hyphenated version of the title text. Something like:

# Welcome to my new blog article
--> website.com/posts/page#welcome-to-my-new-blog-article
@natefinch
Copy link
Contributor

That seems pretty reasonable. I'm not that familiar with that part of the code, but it sounds not too difficult, and worthwhile (no one like ugly anchor text)

@spf13
Copy link
Contributor

spf13 commented Aug 5, 2014

This takes place in the Black Friday library. That leaves us two options.

  1. Patch upstream.
  2. Parse and replace the upstream output

@matsko
Copy link
Author

matsko commented Aug 5, 2014

We should fix it at the source. I'll post an issue on blackfriday.

@matsko
Copy link
Author

matsko commented Aug 7, 2014

I do see a toc_0 inside of https://github.com/spf13/hugo/blob/master/hugolib/page.go#L717 but I'm guessing that is some code to detect the generated set of links.

Could we possibly patch this for now? I haven't gotten any proper updates in the issue I posted on blackfriday.

@matsko
Copy link
Author

matsko commented Aug 24, 2014

Any update on this? I really need this fix.

@spf13
Copy link
Contributor

spf13 commented Aug 25, 2014

Really the only Good way to do it is upstream. Anything else would be a brittle hack that would break the moment they actually implemented it properly.

@spf13
Copy link
Contributor

spf13 commented Aug 30, 2014

Good news
I've merged #454 which allows you to specify id's in markdown.

Bad news.
There's a bug in BlackFriday that ignores this for TOC and tries to use the numbered ids even though they don't exist.

I filed a ticket there about it. russross/blackfriday#112

@halostatue
Copy link
Contributor

I have submitted PRs russross/blackfriday#124 and russross/blackfriday#125 to fix both of these issues with automatic header ID generation. If accepted as I’ve provided, Hugo will require a small additional change to enable the header ID generation extension.

@bep bep added the Stale label Feb 27, 2017
@bep
Copy link
Member

bep commented Feb 27, 2017

@halostatue what is the status of this?

@halostatue
Copy link
Contributor

Those were both merged in 2014. Beyond that, I don’t know. In theory, it should work.

@bep
Copy link
Member

bep commented Mar 1, 2017

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

@bep bep closed this as completed Mar 27, 2017
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants