With enough Cannabis, anything is possible.
I just learned a lot more.
stoned@stoned-desktop:~/media/websites/psychedelicsdaily.com/content$ find .
.
./contact.md
./news
./news/authors
./news/authors/hash-borgir
./news/authors/hash-borgir/Psychedelics-Are-Deeply-Linked-With-The-Human-Condition.md
./news/authors/hash-borgir/Doctors-Are-Using-Psychedelics-To-Treat-Mental-Illness.md
./news/authors/hash-borgir/MDMA-Assisted-Psychotherapy-Explained-by-Rick-Dublin.md
./news/authors/guest-writer
./news/authors/guest-writer/Test.md
OR
stoned@stoned-desktop:~/media/websites/psychedelicsdaily.com/content$ find .
.
./contact.md
./news
./news/authors
./news/authors/hash
./news/authors/hash/Psychedelics-Are-Deeply-Linked-With-The-Human-Condition.md
./news/authors/hash/Doctors-Are-Using-Psychedelics-To-Treat-Mental-Illness.md
./news/authors/hash/MDMA-Assisted-Psychotherapy-Explained-by-Rick-Dublin.md
./news/authors/guest
./news/authors/guest/Test.md
So I have learned that under my SECTION, I can organize the folders in any manner I want, and it they are rendered at site.com/SECTION/article-slug-here (even if the physical location is /content/SECTION/some-dir/ or /content/SECTION/some-dir/some-other-dir/even-deeper-nesting/and-even-deeper/nesting/here/). Which is beautiful! Just what I wanted. I can now organize my author’s articles in /news/ SECTION.
Now, I’m organizing everything in the news section and created authors as a taxonomy
Every article front matter contains:
+++
author = "guest"
authors = "guest-writer-sample"
...
...
+++
Where this author (.Params.author) maps to .Site.Params.authors.[$author] as this is used to fetch the author
And where this authors (.Params.authors) is my taxonomy. So now, all articles show up under /news/, and guest author’s articles will be listed under /authors/guest-writer-sample/ or whatever authors=""
So far, so good. Smoke more Cannabis, and now we type more.
Now, I have this. I am defining author= and authors= in front matter of articles. One is used to pull profile data from .Site.Params.authors and the other is a taxonomy.
I wonder how I can make it so that I just have to specify .Params.author (which maps to .Site.Params.authors array, in which there is a key(array) called .Params.author which has all the author profile data as follows:
[params.authors.guest]
name = "Guest Writer"
first_name = "Guest"
lst_name = "Writer"
display_name = "Guest H. Writer"
bio = "Guest profile has no bio."
short_bio = "Guest profile short bio."
long_bio = "Guest profile long bio is very long and boring."
location = "Colorado, USA"
email = "guest@guest.com"
image = "/images/authors/Guest/Manbrown2.png"
website = ""
github = ""
facebook = ""
twitter = ""
googleplus = ""
pinterest = ""
instagram = ""
youtube = ""
linkedin = ""
skype = ""
How can I make it so that when Hugo creates a taxonomy for authors, it takes the .Site.Params.authors.guest.name and uses that as my taxonomy name, so I don’t have to specify authors= taxonomy.
This way, I can specify author=“guest” in my front matter, just this, and not authors=“guest-writer-taxonomy-here”, and whatever the value for author=“guest”'s name is from .Site.Params.authors.guest.name, that value is used as the taxonomy name.
So for user .Site.Params.authors.guest, if the .Site.Params.authors.guest.name defined in config.toml is “donkeys are fun”, I want this to be my taxonomy name.
If this is not possible, that’s fine.
I hope this makes more sense.
EDIT: I no longer have /content/authors SECTION any longer, becuase now I understand more the organization. The documentation still lacks in areas where my English sucks, and I hope to be able to contribue to the docs so that they are more explanatory.
EDIT: I no longer have to fix my RSS feeds, b/c the whole confusion w/ SECTION and taxonomy is fixed. One last thing I have to do is clean the duplicated code inside my default list template.
Currently the contents are as follows:
{{ $baseurl := .Site.BaseURL }}
<!DOCTYPE html>
<html lang="en">
{{ partial "head.html" . }}
<body>
<div id="all">
<header>
{{ partial "nav.html" . }}
</header>
{{ partial "breadcrumbs.html" . }}
<div id="content">
<div class="container">
<div class="row">
<!-- *** LEFT COLUMN *** -->
<div class="col-md-9" id="blog-listing-medium">
{{ if ne .Kind "taxonomy" }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "article") }}
{{ range $paginator.Pages }}
<section class="post shadow box">
<div class="row">
<div class="col-md-4">
<div class="image shadow">
<a href="{{ .Permalink }}">
{{ if .Params.banner }}
<img src="{{ .Site.BaseURL}}{{ .Params.banner }}" class="img-responsive" alt="">
{{ else }}
<img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="">
{{ end }}
</a>
</div>
</div>
{{$author := index .Site.Params.authors (.Params.author) }}
<div class="col-md-8 post-meta">
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<div class="clearfix">
<p class="author-category">
{{ if isset .Params "author" }}
<a class="" href="{{$baseurl}}authors/{{ .Params.authors | urlize }}/"><i class="fa fa-user" aria-hidden="true"></i>{{$author.display_name}}</a>
{{ end }}
{{ range $index, $tag := .Params.tags }}
<a class="" href="{{$baseurl}}tags/{{ $tag | urlize }}/"><i class="fa fa-hashtag" aria-hidden="true"></i>{{ $tag }}</a>,
{{ end }}
{{ if isset .Params "categories" }}
{{ if gt (len .Params.categories) 0 }}
<a href="{{ $.Site.BaseURL }}categories/{{ index .Params.categories 0 | urlize | lower }}"><i class="fa fa-folder" aria-hidden="true"></i>{{ index .Params.categories 0 }}</a>
{{ end }}
{{ end }}
</p>
<p class="date-comments">
<a href="{{ .Permalink }}"><i class="fa fa-clock-o"></i> {{ .Date.Format .Site.Params.date_format }}</a>
</p>
</div>
<p class="intro">{{ slicestr .Summary 0 200 | markdownify}}...</p>
<p class="read-more"><a href="{{ .Permalink }}" class="btn btn-template-main shadow"><i class="fa fa-list-alt" aria-hidden="true"></i> {{ i18n "continueReading" }}</a>
</p>
</div>
</div>
</section>
{{ end }}
{{ else }}
{{ $paginator := .Paginate .Data.Pages}}
{{ range $paginator.Pages }}
<section class="post shadow">
<div class="row">
<div class="col-md-4">
<div class="image shadow">
<a href="{{ .Permalink }}">
{{ if .Params.banner }}
<img src="{{ .Site.BaseURL}}{{ .Params.banner }}" class="img-responsive" alt="">
{{ else }}
<img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="">
{{ end }}
</a>
</div>
</div>
{{$author := index .Site.Params.authors (.Params.author) }}
<div class="col-md-8 post-meta">
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<div class="clearfix">
<p class="author-category">
{{ if isset .Params "author" }}
<a class="" href="{{$baseurl}}authors/{{ .Params.authors | urlize }}/"><i class="fa fa-user" aria-hidden="true"></i>{{$author.display_name}}</a>
{{ end }}
{{ range $index, $tag := .Params.tags }}
<a class="" href="{{$baseurl}}tags/{{ $tag | urlize }}/"><i class="fa fa-hashtag" aria-hidden="true"></i>{{ $tag }}</a>,
{{ end }}
{{ if isset .Params "categories" }}
{{ if gt (len .Params.categories) 0 }}
<a href="{{ $.Site.BaseURL }}categories/{{ index .Params.categories 0 | urlize | lower }}"><i class="fa fa-folder" aria-hidden="true"></i>{{ index .Params.categories 0 }}</a>
{{ end }}
{{ end }}
</p>
<p class="date-comments">
<a href="{{ .Permalink }}"><i class="fa fa-clock-o"></i> {{ .Date.Format .Site.Params.date_format }}</a>
</p>
</div>
<p class="intro">{{ slicestr .Summary 0 200 | markdownify}}...</p>
<p class="read-more"><a href="{{ .Permalink }}" class="btn btn-template-main shadow"><i class="fa fa-list-alt" aria-hidden="true"></i> {{ i18n "continueReading" }}</a>
</p>
</div>
</div>
</section>
{{ end }}
{{ end }}
<ul class="pager">
{{ if .Paginator.HasPrev }}
<li class="previous"><a href="{{ .Site.BaseURL }}{{ .Paginator.Prev.URL }}">← Newer</a></li>
{{ else }}
<li class="previous disabled"><a href="#">← Newer</a></li>
{{ end }}
{{ if .Paginator.HasNext }}
<li class="next"><a href="{{ .Site.BaseURL }}{{ .Paginator.Next.URL }}">Older →</a></li>
{{ else }}
<li class="next disabled"><a href="#">Older →</a></li>
{{ end }}
</ul>
</div>
<!-- /.col-md-9 -->
<!-- *** LEFT COLUMN END *** -->
<!-- *** RIGHT COLUMN ***
_________________________________________________________ -->
<div class="col-md-3">
<!-- *** MENUS AND WIDGETS *** -->
{{ partial "sidebar.html" . }}
<!-- *** MENUS AND FILTERS END *** -->
</div>
<!-- /.col-md-3 -->
<!-- *** RIGHT COLUMN END *** -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</div>
<!-- /#content -->
{{ partial "footer.html" . }}
</div>
<!-- /#all -->
{{ partial "scripts.html" . }}
</body>
</html>
So as you can see,
{{ if ne .Kind "taxonomy" }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "article") }}
{{ range $paginator.Pages }}
{{ else }}
{{ $paginator := .Paginate .Data.Pages}}
{{ range $paginator.Pages }}
{{ end }}
What I was doing was this: If the page being rendered is not a taxonomy, fetch all the articles with front matter type=“article”, else just fetch all the pages for this node, whatever it maybe.
The reason I was doing this, is because if you remember I had two sections, /news/ and /authors/ - and the template I used hash /content/contact.md which is a single page.
If call .Site.Pages to get all the pages from the site, contact.md (which no front matter) is also rendered and breaks the rendering of the site. The reason why I used .Site.Pages was to grab all the pages from both/all sections. I realized this was also fetching content/contact.md so I decided to put type=article in every front matter, and decided to filter by that type, so contact.md won’t show up and break the site.
Well, this was well and good, until I went to site.com/taxonomy/ and nothing was listed. So I learned, I’d have to get the .Data.Pages for this node, so I had to duplicate the list template code, and depending on whether it was a taxonomy page or not, either display the type filtered articles, or all the Pages for that node/section etc.
Now that I understand a lot more, I can de-dupe my code, and in the list template, only show .Data.Pages, which would then fetch all the pages from /news/ (the only section on the site so far).
(As I need to add more sections, what would be the right way to fetch pages from ALL sections, MINUS the /contents/contact.md (which does not belong to any section). I could create a section called /contact/ and put the contact.md page there, and then pull .Site.Pages (and give contact.md front matter like the rest of the articles).
Anyway, the more Cannabis I consume, the smarter I become.
Thank you for your support and time.