How do I know which folder the Markdown file is in?

Under the content folder there are folders where I grouped my articles and inside each folder there are _index.md and markdown files with my articles.

image

The contents of these _index.md files are as follows (there are many folders, I only gave one example)

---
title: Webmaster Page
url: webmaster
---

What I want to do is to get the url: variable in the _index.md file in the folder where the markdown file is in single.html.

So for example I have an article under the content/webmaster folder. To show that this article is in the webmaster category, I take the url: parameter in the _index.md file under the webmaster folder and link to it. (I also need to get single.html)

Note: I disable Tags and Categories, I don’t use them.

If such a thing is possible, I would be very grateful if you could help me. If not, let me know in a reply and I will try to find other solutions myself.

1 Like

First, why are you setting url to webmaster? That is already determined by the directory name.

Second, if you are rendering webmaster/what-is-the-xss.md and want to get to the section page, use the .CurrentSection method.

2 Likes

I use a multilingual configuration, so sometimes I change the url of the folders according to the language.

.CurrentSection thank you very much for your answer. It gives me the path _index.md.

Is there any chance to get the url: variable in this _index.md?

1 Like

.CurrentSection is a page. So, .CurrentSection.RelPermalink.

2 Likes

Thank you for your answer, it works.

I also discovered that I can get it like this while trying it now.

.CurrentSection.Params.url

1 Like

That will give you the value of url in front matter, but not necessarily the URL of the section.

2 Likes

Yes, I noticed, thank you again for the information. I wanted to write in case users need another parameter and see the topic.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.