BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
14.67k stars 1.85k forks source link

Immutable (direct) link for pages #2374

Closed Vinno97 closed 3 years ago

Vinno97 commented 3 years ago

Describe the feature you'd like When you create a page, its URL contains features like its title and the book that the page belongs to. However, this link can change when it or its parent book are renamed.

It would be great if we could also create URLs that are immutable and always point to a specific page.

I am thinking of a "Get Sharable URL" button, which gives you an url like https://domain.com/ref/<page_hash>. This link can point to the same content as the full page url, or just redirect (like a TinyURL or YouTu.be).

Describe the benefits this feature would bring to BookStack users Documentation is often fluid. Titles change, sections are re-ordered, etc. With just the current implementation, links do break. It makes it so that you cannot just share an URL and trust that the recipient can keep on using it.

One of the last things you want in your documentation is dead links. Even Bookstack's internal links can break.

Lastly, this feature can allow for a more flexible use of BookStack. Without it, I would highly discourage changing anything that might influence the URL of a page. With it, pages can evolve, books can be merged/seperated, etc., all without breaking links.

Additional context I am currently testing how well BookStack would work in our educational instituion. Some co-workers are using it and links got shared with each-other. Now the title of one book was changed, and the pages of all URLs beneath it became invalid. It would be pretty annoying (and likely hinder adoptation) if this kept happening too often.

You can discourage people from changing titles, but that is no real solution. Sometimes its just necessary.


Thanks for making BookStack the system that it is. It is beautiful how something like this can be open source.

I think it can be implemented in a pretty straightforward manner. Pages have unique ids. To prevent enumeration, the unique link id can be something like hash(pageId + salt), where hash() returns the first n characters of a sha256 hash. Alternatively, random hashes can be stored as an extra column in the pages table. This way, you can also detect and prevent accidental collisions, though it may not even be necessary.

I also think that internal linking (between pages) should automatically be done using these page-specific URLs.

ssddanbrown commented 3 years ago

Thanks for the details request @Vinno97 along with an implementation idea.

There is currently an id-based page linking available in the platform at /link/<page_id>. This can easily be generated by selecting some text within a section of the page, you'll get a popover box with this link format:

image

BookStack does offer some level of old-url resolution but this can indeed break depending on the change.

When it comes to links there are many different opinions on what's important and there have been many requests over the years such as: #1969, #1781, #732, #497, #338 and many more.

I'm aware the link format needs to be improved but it will need to be done in a very considerate way that meets the requirements of most, but likely never everyone. At some-point in the future I'll look to to form a proposal for a new URL scheme for feedback. This may include a hash like suggested but will likely need more aside the hash to provide human readable context.

Since there are many existing similar requests to change URL's I'm going to close this off as a duplicate for now but I'll keep in mind your suggestions when it comes to formulating that proposal.

avmaksimov commented 7 months ago

I'm aware the link format needs to be improved but it will need to be done in a very considerate way that meets the requirements of most, but likely never everyone.

Thanks for your answer. But it's already worked with your method if I delete tage informtation and save only link's id. For example: https://kb.mysite.com/link/199 .

For the first time it will be great if somebody add a button for copy permanent link to page with ID instead of page's header.