hugo-blox-builder
hugo-blox-builder copied to clipboard
External projects link in search results
Feature Request
Is your feature request related to a problem? Please describe. Ideally, external projects shouldn't have any specific project page. This can be disabled by including:
_build:
render: never
in their front matter (this way, no actual page is rendered but they still show in portfolio widgets, taxonomy lists and search results, which is fine). When listing external projects in taxonomy lists, they automatically link to the external site. In search results, however, external projects still link to the (internal) project page.
Describe the solution you'd like Make external projects always link to the external site, also in search results, so behavior is more consistent with what we already have in the portfolio widget and taxonomy lists.
Other partials where external projects still link to internal pages rather than to the external sites are (these I think I can fix them myself and could submit a PR):
@gcushen I've got ready a PR addressing this (also for search results, where only the index.json file needs to be modified, see here). Please let me know if it's something worth considering. If not I'm happy just adding it to my site. Thanks!
This issue has been automatically marked as stale because it has not had any recent activity. The resources of the project maintainers are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, consider contributing a Pull Request with a fix.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why or contribute a Pull Request for review.
This issue will automatically close soon if no further activity occurs. Thank you for your contributions.
As per this comment: the project and author system could handle external links in a consistent way. This is, if the user writes
_build:
render: never
in the front matter of an external project, that means he/she wants that project to be truly external (all links to the external site). If not, then all links should go to the internal page (in order to be consistent, not like the current version where some links take to the external site and others to the internal page).
Adding following the lines to /layouts/index.json as suggested in your github repository
{{- if .Params.external_link -}}
{{- $rel_permalink = .Params.external_link -}}
{{- end -}}
Did not work.
However I am running academia, a fork of academic, but still seems to be compatible enough to perform this change, as it would be as simple as simply changing the link from an internal link to an external link. Any suggestions?
Interestingly, changing
{{- $rel_permalink := .RelPermalink -}}
{{- $permalink := .Permalink -}}
To
{{- $rel_permalink := .Params.external_link -}}
{{- $permalink := .Params.external_link -}}
Doesn't work at all, so I'm lost to where the actual linking might be going on. Here's the full file for reference:
{{- /* Generate the search index. */ -}}
{{- $index := slice -}}
{{- $pages := site.RegularPages -}}
{{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}}
{{- $pages := $pages | union (where (where site.Pages "Kind" "section") "Type" "docs") -}}
{{- /* Add author pages to index so their bios can be searched. Hide empty `/authors/` node. */ -}}
{{- $pages := $pages | union (where (where site.Pages "Section" "authors") "Params.name" "!=" nil) -}}
{{- range $pages -}}
{{- /* Do not index drafts or private pages. */ -}}
{{- if and (not .Draft) (not .Params.private) -}}
{{- /* Generate page description. */ -}}
{{- $desc := "" -}}
{{- if .Params.summary -}}
{{- $desc = .Params.summary -}}
{{- else if .Params.abstract -}}
{{- $desc = .Params.abstract -}}
{{- else -}}
{{- $desc = .Summary -}}
{{- end -}}
{{- $authors := .Params.authors -}}
{{- $title := .Title}}
{{- $rel_permalink := .RelPermalink -}}
{{- $permalink := .Permalink -}}
{{/* Correct the title and URL for author profile pages. */}}
{{- if eq .Section "authors" -}}
{{- $title = .Params.name -}}
{{- $username := path.Base (path.Split .Path).Dir -}}
{{- with site.GetPage (printf "/authors/%s" $username) -}}
{{- $permalink = .Permalink -}}
{{- $rel_permalink = .RelPermalink -}}
{{- end -}}
{{- else -}}
{{/* Include a user's display name rather than username where possible. */}}
{{- if .Params.authors -}}
{{- $authorLen := len .Params.authors -}}
{{- if gt $authorLen 0 -}}
{{- $authors = slice -}}
{{- range $k, $v := .Params.authors -}}
{{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}}
{{- $person_page := site.GetPage $person_page_path -}}
{{- if and $person_page $person_page.File -}}
{{- $person := $person_page.Params -}}
{{- $authors = $authors | append $person.name -}}
{{- else -}}
{{- $authors = $authors | append ($v | plainify) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Add page to index. */ -}}
{{- $index = $index | append (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "publishdate" .PublishDate "lastmod" .Lastmod.UTC.Unix "expirydate" .ExpiryDate.UTC.Unix "lang" .Lang "permalink" $permalink "relpermalink" $rel_permalink "title" $title "summary" (plainify $desc) "content" .Plain "authors" $authors "kind" .Kind "type" .Type "section" .Section "tags" .Params.Tags "categories" .Params.Categories) -}}
{{- end -}}
{{- end -}}
{{- $index | jsonify -}}
I'd suggest you report this in the correct repo.
I haven't because I've reported two issues and they don't seem very active, I was just trying to understand what the differences are and, since the file itself looks the same, I was trying to come up with a solution and post it there instead of an issue, as I'm not expecting an answer any time soon.
I haven't because I've reported two issues and they don't seem very active, I was just trying to understand what the differences are and, since the file itself looks the same, I was trying to come up with a solution and post it there instead of an issue, as I'm not expecting an answer any time soon.
Any reason why you're using Academia instead of the more mature and better supported Wowchemy? I don't know anything about the inner parts of the Academia theme and how much they changed it compared to Wowchemy, so your issue may be due to multiple factors.
I couldn't figure how to clone the repository to make it act as a theme using simply hugo without using netlify or something like that, I usually like to keep things as minimal and independent as possible although now I know that I can do that too with the wowchemy theme.
Also the defaults were much better, even though that's subjective obviously, but I just liked it more, the only downside is in fact the support and each time I try to do something I have to adapt to the current theme which isn't easy especially for me who doesn't understand any of this, hopefully since I only want to do some minor improvements to the academia theme, I can make it happen by understanding the differences or getting the support from them. In the future if the theme changes a lot I might have to reconsider and export all my content from academia to academic, but so far I think it's overall better.
Closing due to lack of demand from users and lack of contributions. If anyone still wants to submit a PR to add the requested feature, they are welcome :)