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

Get content file filename #210

Closed
bricebou opened this issue Mar 14, 2015 · 1 comment · Fixed by #252
Closed

Get content file filename #210

bricebou opened this issue Mar 14, 2015 · 1 comment · Fixed by #252

Comments

@bricebou
Copy link

Hi,

I was wondering if there was a way to get the filename of a "blog post" ?

In fact, I'd like to get the page.url and to remove the filename from it to make a link to the upper level.

Let's says I have a blog post here : http://example.com/tuto/test
I'd like to get the link: http://example.com/tuto/

Is there a way this using some kind of page.filename or using a Twig filter ?

Thanks in advance.

@theshka theshka closed this as completed Apr 28, 2015
@stefanbohacek
Copy link

Is there a way to do this in the latest version?

The best I could do was something like this:

 {% include 'contribute.html' with {'relative_path': current_page.url | split(base_url) | last } %}

Then in contribute.html, I have this:

<p>
  This website is <a href="https://github.com/botwiki/botwiki.org">open source</a>. <a href="https://github.com/botwiki/botwiki.org/tree/master/content{{relative_path}}.md">Click here</a> to edit this page.
</p>

This obviously doesn't work, since some files are index.md and some are, for example, holidaybot4000.md.

Also, I believe that from the snippet above it should also be clear what I'm trying to do.

The only solution I can think of is something like a custom Twig function, but I can't really see how to add one.

Any help would be very appreciated.

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

Successfully merging a pull request may close this issue.

3 participants