getzola / hyde

Port of https://github.com/poole/hyde to Zola
MIT License
76 stars 51 forks source link

content order is inconsistent #32

Open amrirasyidi opened 1 year ago

amrirasyidi commented 1 year ago

The ordering part of the index.html seems to be inconsistent in my end.

        <div class="content container">
            {% block content %}
                <div class="posts">
                    {% for page in section.pages %}
                      {% if page.extra.front_page %}
                        <div class="post">
                          <h1 class="post-title">
                            <a href="{{ page.permalink }}">
                              {{ page.title | safe }}
                            </a>
                          </h1>

                          <span class="post-date">
                            {{ page.date | date(format="%Y-%m-%d") }}
                            {% if page.authors %}
                              by {% for author in page.authors %}{{ author }}{% if not loop.last %}, {% endif %}{% endfor %}
                            {% endif %}
                          </span>
                          {{ page.description }}
                        </div>
                      {% endif %}
                    {% endfor %}
                </div>
            {% endblock content %}
        </div>

Sometime when I add | reverse it actually sort the post descendingly by its date (which is I wanted to be), but the other time it is ascending. How to properly sort the posts by its date in descending order?

Keats commented 1 year ago

How are you sorting the pages in the main section? Eg what's the front-matter of content/_index.md (which is not present in this repo, not great).

amrirasyidi commented 1 year ago

Hmm. I didn't create a main section, the folder tree of content is almost identical from what I got in this repo.

I initially want to create 3 sections, blog, about, and categories, but it seems I got the same problem as this. That is why, currently I added a new front-matter in my posts, front_page (boolean) to decide which posts (page.md) to show in the landing page.

So in my web, now about is just another post instead of a dedicated section with a post inside it.

Do you have a suggestion how should I create sections (the foldering) and make it work? e.g. what script should I add/edit in which file.

And when you say "(which is not present in this repo, not great)", do you mean, my repo, or this hyde repo? πŸ˜…

And, thanks for the response btw πŸ₯‚

Keats commented 1 year ago

this hyde repo

This repo, the hyde one. It should have a working example and an updated README, I'll do that tonight if I remember.

For this theme, all the articles in the content/ directory will be essentially the blog post and you can create the about section separately. Categories sound like taxonomies and you should probably use Zola itself rather than creating your own section.

The layout should be something like:

content/
  _index.md
  article.md
  article2.md
  about/
     _index.md
amrirasyidi commented 1 year ago

I reorganize my web foldering in github, now use a *duplicated submodule to put the hyde folder under themes.

β”œβ”€β”€β”€content
β”‚   β”œβ”€β”€β”€about
β”‚   β”‚       index.md
β”‚   └───blog
β”‚       β”‚   _index.md
β”‚       β”œβ”€β”€β”€1_first_post
β”‚       β”‚       index.md
β”‚       β”œβ”€β”€β”€2_second_post
β”‚       β”‚       index.md
β”œβ”€β”€β”€sass
β”œβ”€β”€β”€templates
β”‚   β”‚   about.html
β”‚   └───shortcodes
β”‚           image.html
└───themes
    β”œβ”€β”€β”€hyde1
    β”‚   β”‚   ...

I think the ordering issue is fixed now, I don't see the post ordering changes every time I update the file.

But I still have this issue where the index.html shows nothing. As a side note, I know hyde theme from this website, I see it works just fine.

*I duplicated the original hyde repo, because I adjust some of the file and it requires me to push to the original repo in different branch, I'm not so familiar with submodule, I'm afraid this means a merge request to the hyde master branch, hence I opt for a safer way πŸ™ƒ maybe you have advice on this?

Keats commented 1 year ago

Why are you nesting the blog in content? This theme expects all the articles to be in the root of the folder so it's normal that nothing is showing. Move all the files/folders from content/blog/ to content/ and it should work. I've added some docs in https://github.com/getzola/hyde/pull/33

amrirasyidi commented 1 year ago

ah, I see. It's working now

But now the about is a section, now there will be an extra click to the about page.

β”œβ”€β”€β”€content
β”‚   └───about
β”‚       β”‚   _index.md
β”‚       └───about
β”‚               image.png
β”‚               index.md

My workaround currently is to add this in the config.toml

[extra]
# Put all your custom variables here
hyde_links = [
    {url = "about/about", name = "About"},
]

I guess this is expected?

amrirasyidi commented 1 year ago

Also, I think it is good to add the expected folder tree in the documentation, just like what you said here

"This theme expects all the articles to be in the root of the folder"

probably like this(?)

β”œβ”€β”€β”€content
β”‚   β”‚   _index.md
β”‚   β”œβ”€β”€β”€content_1
β”‚   β”‚       index.md
β”‚   β”œβ”€β”€β”€content_2
β”‚   β”‚       index.md
β”‚   └───about
β”‚       β”‚   _index.md
β”‚       └───about
β”‚               index.md
β”œβ”€β”€β”€sass
β”œβ”€β”€β”€templates
└───themes
    β”œβ”€β”€β”€hyde
    β”‚   β”‚   ...

I opened a pull request for this if you don't mind.