Is it possible to get nice urls for kirbytext (file: ) links?

I have a page to which I have added a pdf file

I am linking to that file with kirbytext
(image: Flyer.jpg link: Flyer.pdf )

Which goes to a url formated like this

Is there a straight foward way to convert the link url so it loads formated like this.

Yes, that’s possible, but because of the needed redirection this is not recommended.

@lukasbestle: This solution would only work if you modified the image tag, though?

Yes, exactly. When using it inside a Kirbytag, you would need to overwrite the tag with your own implementation.

@lukasbestle Thanks for that but because of the redirect it is not straight foward.

I have settled on creating a pdf folder and using relative links as the easiest way of getting nicer urls.

I made an invisible folder in content called pdf/ and added the pdfs.
Then I link to it with kirbytext (image: Flyer.jpg link:pdf/Flyer.pdf )

Which gets me
and is pretty close to what I wanted.

Great solution!

Yes, the redirect is not perfect but it is required because web servers are better at serving static files than PHP is.

Is there an updated way of linking to Site files than this? Having a client upload PDF files in the Panel is a desirable solution, too.
But I’d really prefer using a directory just inside Root to serve them like this.
Hoping there’s an easier solution.

I did read all of this, too:

@luxuryluke You are posting in a very old Kirby 2 thread. So the solution to changing the URL of files is in the post you linked to.

What do you mean?

Ah. Yes, I mean like having a folder called /pdf/ at the root level for storing common files that can be referenced all over the site but managed from within the panel and using simple file urls instead of long ones with hashes and strings in it.

But after reading further I don’t think easily doable.

You can put them into the site object (root of the content folder) or a central media folder within the content folder. Outside the content folder is not possible if you want to use the files in the Panel.

You could then use files fields to select files from this folder where needed.

1 Like