I’m trying to structure my .md files by category directories. Does this give me a way to sort my content by directory on the list page?
Also how do I set up my image folders for content?
I’m trying to structure my .md files by category directories. Does this give me a way to sort my content by directory on the list page?
Also how do I set up my image folders for content?
The question is a little broad, do you have a specific set of tasks that you want to do so that it’s easier to help you out?
In general, when a template is applied, you have access to the page variables of the page that it’s being rendered, such as .Pages
and Sections
, both of which you can range to get the .Title
and .RelPermalink
of each page in the collection.
For example, this could go in your content/_default/list.html
:
{{range .Pages}}
<a href="{{.RelPermalink}}">
{{.Title}}
</a>
{{end}}
When you have a slice (or any collection) you can filter and sort using the functions where and sort respectively.
Was this close to what you needed?
Sorry, I mean when I am creating my .md files (I’m batching out products in python to create the file) I want to put them into a directory (different product types) from there I want to be able to have items be displayed from a drop down FROM the directory of .md files.
On top of that, I’m exporting all my images into a images/products
folder is this the proper place to get page images?
If this is still confusing let me know.
To be honest, I still don’t quite get it. A minimal repo would be ideal, but let me try to see if I get it.
From what I understand, you have a directory that looks like this:
├───content
│ _index.md
│
└───products
bicicle1.md
bicicle2.md
bicicle3.md
car1.md
car2.md
car3.md
motorcycle2.md
motorcycle3.md
motorcycles1.md
_index.md
And you want to generate a file (public/products/index.html
) that has a list of all the products, like this one (I use list tags, but if you want a dropdown menu you’d need the select tag)
<ol>
<li>products\bicicle1.md</li>
<li>products\bicicle2.md</li>
<li>products\bicicle3.md</li>
<li>products\car1.md</li>
<li>products\car2.md</li>
<li>products\car3.md</li>
<li>products\motorcycle2.md</li>
<li>products\motorcycle3.md</li>
<li>products\motorcycles1.md</li>
</ol>
Am I getting close?
About the images, I don’t have much experience. The easiest thing is to put them under static
(/static/images/products
) because that just copies the folder images/products
straight to the output folder (/public
)** . But there are more advanced techniques, even with some image processing. Maybe someone else can help you with that?