kc0bfv / autophugo

AutoPhugo [ˌɔtoʊˈfjuːgəʊ] is a gallery/photoblog theme for Hugo that's a little more automatic than Phugo.
Other
97 stars 56 forks source link

Adding blog posts? #11

Closed Masqued closed 3 years ago

Masqued commented 3 years ago

Hello,

I'm in the process of migrating my WordPress photography site to Hugo using your beautiful theme. I would like to be able to add post types of blog (or posts, or whatever). I have created the existing blog posts in the root level content/posts directory. That directory also has its _index.md file. I have also added a posts.html file in the root layouts/posts directory, which is essentially a list.html file (but not the same as the theme list.html file).

As I understand Hugo's template lookup order, this should cause Hugo to use my posts.html file instead of the theme's list.html file. However, when I run hugo --verbose server I get an error:

INFO 2021/01/09 14:54:51 Using config file: Start building sites … INFO 2021/01/09 14:54:51 syncing static files to / ERROR 2021/01/09 14:54:51 No thumbnail image found for: Blog Built in 212 ms Error: Error building site: logged 1 error(s)

"Blog" is the page title of the _index.md file in the content/posts directory. My posts.html template does not require any thumbnail image. That makes me think that it is using a template from the theme - even though the lookup order seems to indicate that it shouldn't be doing that.

Before I added the blog section, everything was working correctly.

Any help you can provide would be greatly appreciated! Thanks so much for your work on this theme!

kc0bfv commented 3 years ago

Hey Masqued! This is interesting to me - I would like to see what your end product looks like.

Hugo's lookup order is a regular source of confusion for me. If I was doing this thing more regularly I wouldn't get confused - but the system has a lot of parts and I'm usually away from this for long enough to forget how stuff works.

I think - trying this out, I've determined that that error isn't coming from the point where Hugo is building your Blog page/section - it's coming from when it's building the root list / home page. When it's trying to build that home page it looks for thumbnails for the sections - so it's expecting content/posts/_index.md to specify an "albumthumb" or to be able to autopick one from the assets.

So - the error here is confusing. Honestly - Hugo should automatically specify which file it's building when the error occurs, but it doesn't. I'll make that change in code so the error messages are more helpful. I think if you just update the theme and try with those improved error messages you'll see it's building _index.md - and if there's no directory output then that's the root _index.md.

But also - you can specify "albumthumb" in your content/posts/_index.md file. Whatever you put in there will be the image picked to represent the posts link from the main page. Then - since your posts will have a different layout, everything under posts will look different. I tried this out a bit and it seems to work.

kc0bfv commented 3 years ago

Please close this if it helps - gonna commit the code now.

Masqued commented 3 years ago

Thanks for the quick commit!

I agree - the lookup order is confusing. I've been over the doc page on it several times, and chose the specific blog layout filename in hopes it would be preferred to the default list.html file in the theme.

After updating the theme, and adding an albumthumb image to the _index.md file, here's the output I get:

hugo --verbose server -D INFO 2021/01/10 20:32:28 Using config file: Start building sites … INFO 2021/01/10 20:32:28 syncing static files to / ERROR 2021/01/10 20:32:29 When processing '_index.md', no thumbnail image found for: Blog Built in 414 ms Error: Error building site: logged 1 error(s)

The enhanced error messaging confirms that it is the index file for the blog directory that is the one that is causing the error. However, I don't understand why, when there is an image given, that it would still cause the same error.

BTW, I tried putting the image in the static folder, and when that didn't work, I put a copy in the content/blog folder. The result was the same.

It wasn't my intent to cause you a lot of extra work. I can publish the site without a blog, and consider adding the blog to a separate subdomain, using another theme, if this becomes too much of a burden.

Thanks for you help!

kc0bfv commented 3 years ago

Ah - did you add an albumbthumb on your blog?

So - content/posts/_index.md should have the albumthumb (I preesume that's the file that has the title "Blog" too... that's what the : Blog should mean)

kc0bfv commented 3 years ago

Re: work - no worries! Wasn't much. The error messages are more helpful now too.

Masqued commented 3 years ago

Yes, I did add an albumthumb to the Blog page (the _index.md in content/posts). The only other thing I could think of was that I wasn't properly identifying the location of the albumthumb image. I put this albumthumb: "image.jpg" and first put the image.jpg file in the static folder. When that didn't work, I moved it to content/blog which also didn't work. Then I moved it to content/blog/images and changed the entry in _index.md to albumthumb: "blog/images/image.jpg. Unfortunately, the error was the same each time.

kc0bfv commented 3 years ago

So, right now it would need to be part of the assets folder structure. Just like with the album photos. You could put it in assets/posts I think, and then reference it as "posts/image.gif"

That's basically how you make an album - do the same thing as the exampleSite albums. But then, when Hugo goes to render the actual page it'll find your template.

Another debugging trick I found useful - when I ran Hugo as a server and simulated the error you have, I got no output because it killed itself. But - when I ran Hugo to produce the page on the hard drive (like, just running "hugo" so it creates the "public" directory), then I still got output despite the error, and I could look at those pages and see what was happening a little.

On Mon, Jan 11, 2021, 05:00 Masqued notifications@github.com wrote:

Yes, I did add an albumthumb to the Blog page (the _index.md in content/posts). The only other thing I could think of was that I wasn't properly identifying the location of the albumthumb image. I put this albumthumb: "image.jpg" and first put the image.jpg file in the static folder. When that didn't work, I moved it to content/blog which also didn't work. Then I moved it to content/blog/images and changed the entry in _index.md to albumthumb: "blog/images/image.jpg. Unfortunately, the error was the same each time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kc0bfv/autophugo/issues/11#issuecomment-757875864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALGLJJNLFIQLT3SARAB22TSZLK4TANCNFSM4V324EHA .

Masqued commented 3 years ago

That worked perfectly! Thanks - of all the places, I missed assets as the location for the image file!

Now I will get to work on getting the blog section to display properly (I need to work on its template a bit).

Thanks again! I'll close this now.