I'd like to use the Posts widget, but change its name (and url) to "blog" instead. Is there a way to make this work?
I tried simply changing the folder path to blog/ instead of post/, but this broke it, and I started to try using the custom widget but realized I'd lose all of the functionality. I'd be grateful to be pointed along the right path.
Refer to permalinks in the documentation.
You can try something like adding the following near the top of your config.toml (before the [params] section):
[permalinks]
post = "/blog/:slug"
Thanks for the quick response! Sorry I wasn't more clear in the issue. Yes, I've got the permalinks option set to "/blog/:year/:month/:slug", and that works great. The urls for all the posts themselves are fine. However:
Posts (I'd like that to be Blog)[permalinks] config that you added since I discovered that Hugo doesn't yet support a smart way to change the URL for sections/archives (see https://github.com/gohugoio/hugo/issues/3354). Rename post folder to blog. You'll need to delete the example posts (except _index.md) as they reference the post folder, which will cause errors.config.toml, scroll to bottom of file and change the Posts link to:[[menu.main]]
name = "Blog"
url = "#blog"
weight = 3
blog.mdblog/_index.md and in your new blog widget home/blog.md.I did the renaming in my private fork since very beginning when I switched to this template, by renaming the related files and modifying some htmls listed in git grep -i post.
Never had any problem with git merge in the last period.
Also don't forget the 404 page.
Note that the permalink method of adding the following just above [params] section of config
[permalinks]
post = "/blog/:slug"
can work with archive pages too if you add aliases = ["/blog/"] to your post/_index.md.
I didn't mention it earlier as it will redirect /blog/ archive page to /post/ rather than rename it, so it's not ideal - but may be useful to someone.
- Remove the [permalinks] config that you added since I discovered that Hugo doesn't yet support a smart way to change the URL for sections/archives (see gohugoio/hugo#3354). Rename post folder to blog. You'll need to delete the example posts (except _index.md) as they reference the post folder, which will cause errors.
- In config.toml, scroll to bottom of file and change the Posts link to:
[[menu.main]]
name = "Blog"
url = "#blog"
weight = 3- To change the widget link, simply rename the widget to blog.md
- Also, you can edit the title from Posts to Blog in your new blog archive at blog/_index.md and in your new blog widget home/blog.md.
Doing only this gave me the error when I tried to run hugo:
ERROR 2017/10/26 16:44:59 Error while rendering "home": template: theme/index.html:1:3: executing "theme/index.html" at <partial "widget_page...>: error calling partial: template: theme/partials/widget_page.html:23:9: executing "theme/partials/widget_page.html" at <partial $widget $par...>: error calling partial: Partial "widgets/blog.html" not found
Changing post.html to blog.html as well as a bunch of references in there from post->blog got rid of the error, and now the menu item and http://www.nequals.me#blogare there, but the widget doesn't actually display the blog posts. I must be missing one final piece...
post.html does not need to be changed to blog.html, and index.html/widget_page.html do not need to be altered. I meant change home/post.md to home/blog.md. The widget variable in your home/blog.md should not be changed - it should remain as widget = "posts".
Also, you'll want to specify type = "post" in the frontmatter of your posts in order for them to be fully recognized as blog post type of content.
Ahh, my mistake. (Also, incidentally, thanks for being so responsive, sorry getting this right is taking such effort). I've reverted the stuff in the theme, and changed back to widget = "posts". Also added type="post" to all posts.
I think it's close. The one outstanding thing is that the link from the widget "more posts" links to '/post/'. But when I build and push the site, there's nothing at /post/ (I get a 404 error). All of the links in the widget are going to the right place, and those pages are built. (/blog/ is still with all of the posts, though formatted slightly differently than /post/ was when it was working).
If I remove the alias=["/blog/"] from _index.md, the behavior seems the same. (eg "More posts" link goes to /post/, but there's nothing there. /blog/* links are all working). Note, all of the above is without [permalinks] set in my config.toml file. Changing that back to post = "/blog/:year/:month/:slug"), doesn't change anything, but including blog = "/blog/:year/:month/:slug" seems to work, though the "More posts" link is still broken.
To attempt to fix your More Posts link, you can add aliases = ["/post/"] to your blog/_index.md front-matter. Alternatively, the hard-coded <a href="{{ "/post/" | relLangURL }}"> can be changed to <a href="{{ "/blog/" | relLangURL }}"> in the posts.html file which you found earlier.
Hopefully, Hugo team will implement https://github.com/gohugoio/hugo/issues/3354 soon and then this URL customization process will be much simpler.
The alias thing worked - awesome! Thanks a bunch.
Incidentally, the styling of the /blog/ page isn't the same as the default /post/ page (the post titles are blue and slightly smaller), but this doesn't bother me over much.
Ideally, you would be able to specify type = "post" in blog/_index.md so that it is recognized as your new post archive page. However, there is currently a bug in Hugo which prevents type working on _index.md archive pages (see https://github.com/gohugoio/hugo/issues/3005).
You can attempt to work around this by copying themes/academic/layouts/section/post.html to layouts/section/blog.html, relative to the root of your site and creating the layouts/section/ folders if necessary. (Note: if you update the theme in the future, you may need to perform this process again so that your version of the file gets any available update applied to it.)
Ideally, you would be able to specify type = "post" in blog/_index.md so that it is recognized as your new post archive page.
Yeah, I actually did try this and noticed it didn't work. I'll avoid messing around in the theme so as not to mess with future updates. The functionality I have now is great - thanks for making such a great theme!
It seems that the upstream enhancement that you referred to is working, yet when I add type: "post" in blog/_index.md, the blog page still has different styling from what the posts page was. Should it be working and I need to reconfigure, or is it still not working and I misread the thread?
Most helpful comment
You can try something like adding the following near the top of your
config.toml(before the[params]section):