Which folder should I put my static files in Jekyll?

后端 未结 2 1991
逝去的感伤
逝去的感伤 2021-02-20 05:31

While I am looking the doc. I saw the following document structure,

.
├── _config.yml
├── _drafts
|   ├── begin-with-the-crazy-ideas.textile
|   └── on-simplicit         


        
相关标签:
2条回答
  • 2021-02-20 06:12

    Assuming you have your gallery images in a structure like

    -img
      -gallery
        -image1.png
        -image2.png
        etc.
    

    you can access them in a collection or page like this:

    {% for image in site.static_files %}
    {% if image.path contains 'img/gallery' %}
        <p>{{image.path}} - {{image.modified_time}}</p>
        <img src="{{site.baseurl}}{{image.path}}">
    {% endif %}
    {% endfor %}
    

    This goes through all static files and check for a certain path (img/gallery in this example).

    Than you can access the static file metadata for that file. (I named it 'image' in this example but you can name it whatever you want after the for keyword).

    I think it doesn't make too much sense to put something like this in a blog post but rather in a page or a collection.

    0 讨论(0)
  • 2021-02-20 06:14

    A static file can be placed anywhere within the site directory that is not a collection of some sort. So not within a directory that begins with "_". What makes it static is the fact that it does not have YAML frontmatter.

    Id recommend making a directory named "assets" or "images" and have them in there.

    edit:

    what are you trying to use the feature for?

    0 讨论(0)
提交回复
热议问题