Hugo: Disable single page output for designated sections

Created on 19 Jun 2017  路  13Comments  路  Source: gohugoio/hugo

As of Hugo 0.23 there is no way to designate a section of content to not output to single page while simultaneously use that content in other contexts of the site.

For a generic example, if I have a section called "authors," but do not want each author to have their own page on the site, yet I do want to use the entries on article pages or an aggregate/list "authors" page.

Data files are currently the most non-hackish way of accomplishing this, However, data files are not necessarily the best format for every type of content, particularly for content creators who may find it easier to create and manage discrete documents.

I think the best way to accomplish this would be configuration variable, such as disableOutput = ['section-name', 'another-section]

_I'm not sure if disableOutput is descriptive enough to capture that it's only skipping single pages. I used this to be consistent with disableKinds._

Enhancement

Most helpful comment

I'm currently using this hack as posted in the forums:

If layouts/foo/single.html and layouts/section/foo.html are zero-length, no files will be published for section foo, but the content can still be retrieved through taxonomies, etc. This was briefly broken in 0.20-0.20.2, but was fixed in 0.20.3.

This works for me as of Hugo 0.26.

All 13 comments

I assume Permalink etc. would return blank for these pages? So they should not be in sitemap, .Site.Pagesetc., only in the section's page list?

Yes. I was thinking that Sitemap would be separate a separate issue, but what you say looks like a logical conclusion to me.

It may not be important at this point, but perhaps disableOutput should be disableSections though still not sure that's descriptive enough.

I was thinking that Sitemap would be separate a separate issue

It cannot be a separate issue. We have nothing to link to in this case (no file on disk), so it would be confusing to put them in sitemap etc.

@budparr can you look at the start of my proposal in #3651 and consider if that could cover the needs described in this issue?

Thanks for thinking of this. Honestly I don't understand "bags" so much yet. ~Seems like a higher level grouping than sections to include images, as far as I can tell.~

All I want is to have a section not create single pages while still using the content elsewhere (list view). ~Perhaps each "bag" having its own configuration file is the point here, and I suppose that would work.~

I'm currently using this hack as posted in the forums:

If layouts/foo/single.html and layouts/section/foo.html are zero-length, no files will be published for section foo, but the content can still be retrieved through taxonomies, etc. This was briefly broken in 0.20-0.20.2, but was fixed in 0.20.3.

This works for me as of Hugo 0.26.

Could this be generalized to include disabling single page output for individual content files (presumably via front matter), or should that be a separate issue?

For background see: https://discourse.gohugo.io/t/how-not-to-render-content-as-a-page/2208/3

Could this be generalized to include disabling single page output for individual content files (presumably via front matter),

It would be natural that this issue would cover both.

I have deliberately waited with this issue until I see how my page bundle branch turns out (that has taken more time than planned), which will give you some sort of "virtual pages", example:

ls /blog/my-article
index.md
pretty-picture.png
some-content.md
some-more-content.md

In the above (in how the world looks to me right now), index.md will be the "index content file" with references to a set of resources (range .Resources will list all).

The big question is: Should all of these resources be "permalinkable"?

  • The image: Yes.
  • The "some more content". Probably not. You most likely want to use those as building blocks for the main page.

Disabling whole sections is one thing but would it not also make sense to do this on a per page basis in Front Matter?

Something like:

disableOutput = true
+++

An example of this might be a blog that also references external content. Whilst you could have different sections this it results in a lot of duplication and complex joins on ranges and this isn't good for content management or development.

Personally I'd be more than happy if .RelPermalink and similar properties were blank when this was used and it was up to developer to override the sitemap, rss or other templates where you might not want these items to appear.

This will be handled by #4311

Couldn't this already be handled using section/branch bundle organization?

By "this", I mean the feature request that @budparr originally made.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrissparksnj picture chrissparksnj  路  3Comments

sigma picture sigma  路  3Comments

vielmetti picture vielmetti  路  3Comments

nikolas picture nikolas  路  3Comments

artelse picture artelse  路  3Comments