yousinix / portfolYOU

A beautiful portfolio Jekyll theme that works with GitHub Pages.
https://yousinix.github.io/portfolYOU
MIT License
1k stars 598 forks source link

How to add new category? #49

Closed Dishant-P closed 3 years ago

Dishant-P commented 4 years ago

I have little to no idea about this, so sorry if the issue is too naive. But I wanted to know how can I add same page like Blog, and rename it and add other content there. So same theme like the blogs page but different content. Thanks.

lillemets commented 4 years ago

There's actually a better implementation of this, one that is used by some Jekyll templates. Each category or tag could be presented as a separate menu item. So all the posts that have a tag something are shown if you open something from the menu. I'd love to see this implemented here, too.

yousinix commented 3 years ago

First of all, sorry for the late response.

To add a new category like posts or projects, you need to do the following — I would assume that the new category is called articles:

  1. Add the new category to _config.yaml:

    collections:
      # ....
      articles:
        output: true
        permalink: /articles/:name
    
    # ....
    
    defaults:
      # ....
      - scope:
          path: ""
          type: "articles"
        values:
          layout: "page"
  2. Create a folder called _articles and add your markdown files there. _You must follow the same front matter as posts.

  3. Create a page called articles.html in pages directory and add the following content to it:

    ---
    layout: default
    title: Articles
    weight: 5
    permalink: /articles/
    ---
    
    <div class="card-group mt-2">
    
        {% for post in site.articles %}
            <!-- Note that this must be called "post" because the post-card wasn't
                 made to be reused, we might improve this in the future to allow this. -->
            {% include blog/post-card.html %}
        {% endfor %}
    
    </div>
jasoncwong commented 3 years ago

Redirected here ->

So this only works for creating a new category that resembles Blog but not Projects?

I followed the steps to try to create a category that resembled projects but could not get it to work.

In particular, I called include project/project-card.html and obtained blank blobs, and if I called include project/index.html I did not get my projects in the new category... and got repeated sets of projects in the projects folder.

`

{% for project in site.team %}
    <!-- Note that this must be called "post" because the post-card wasn't
         made to be reused, we might improve this in the future to allow this. -->
    {% include projects/index.html %}
{% endfor %}

{% for project in site.team %}
    <!-- Note that this must be called "post" because the post-card wasn't
         made to be reused, we might improve this in the future to allow this. -->
    {% include projects/project-card.html %}
{% endfor %}

`

yousinix commented 3 years ago

As I stated above, the project and blog cards weren't made to be reused — this was due to poor design and I am planning to change this in the future when I have time. Therefore, you have to provide the variables needed by project-card.hrml as below, but using your new category (site.team in your case) instead of site.projects in the for loop:

https://github.com/YoussefRaafatNasry/portfolYOU/blob/479d51df4b5c11f691211be47c5f06426c6c6d32/_includes/projects/index.html#L37-L54