kishaningithub / hugo-creative-portfolio-theme

Port of the creative portfolio theme to Hugo
https://themes.gohugo.io/hugo-creative-portfolio-theme/
MIT License
445 stars 291 forks source link

Keeping homepage URL as base URL #46

Open keanemind opened 6 years ago

keanemind commented 6 years ago

With the recent changes to allow for multiple portfolios, the theme now forces the homepage to be a subfolder. For example, the homepage of the example site is no longer https://example.org. Instead, the user is redirected to https://example.org/portfolio/.

I would prefer it if the homepage did not redirect to a subfolder, since I don't like the way it looks in the address bar. I know this is a small thing, but it also has a side effect of causing Hugo to set the homepage's .Title variable (page title in the browser tab) to the pluralized folder name. For example, if the homepage's folder is "portfolio", as it is for the example site, the page title will be "Portfolios". In order to change this, I have to add an _index.md file inside the "portfolio" folder with contents

+++
title = "Creative Portfolio"
+++

to keep the homepage's page title consistent with the website name. In my humble opinion, this is not a preferable default behavior for the theme.

What do you think? Is there a way to have multiple portfolios, and yet also keep the homepage URL as the base URL?

kishaningithub commented 6 years ago

@keanemind As of now i don't but i will rethink about this. Suggestions are always welcome!

keanemind commented 6 years ago

What I did to try to address this on my own site is I changed the index.html layout back to what it was before, and then added an if statement to the portfolio.html layout where I check if the current URL is the homepage. If it isn't, then I have the block of code that's currently there: {{ range .Data.Pages }} and then the masonry box. However, if the current URL is the homepage, I instead use {{ range (where .Data.Pages "Section" "home-folder's-name-here") }} to iterate and generate the masonry boxes.

This might be a bit of a confusing explanation, so here's a link to the same changes but in a commit in my fork of the theme: https://github.com/keanemind/hugo-creative-portfolio-theme/commit/7857c5a2112495d64658aca0168aff2ab46bb394

To be honest, I'm not that familiar with Go templates and I don't know if that's the best way to do this, but it seems to be working without causing other issues so far.

Dapuva76 commented 5 years ago

Totally agree with keanenmind. Used this theme in the past and really liked it, but had to abandon it because loadtimes were too long. Want to use it for a different project now, but the change to the default title feels weird. Just curious, if I have folder called "story", does it expand to "storys"?

tormodvolden commented 4 years ago

I cannot get keanemind@7857c5a to work, simply checking out his branch and using the exampleSite folder (adding a themes folder with a soft link to ../..). I have tried hugo 0.40, 0.68 and 0.73. The resulting public/index.html has an empty grid class div. Did it ever work in the exampleSite folder?