Rename list pages url via [permalinks]

The url structure of mywebsite should be like this:
/ - the index
/blog/ - a blogs index
/blog/post2 - different posts
/blog/archive - the blogs archive

The structure in the directory content ist:

blog |-post1 |-post2

Since the blogs index is nothing but a first text about the blog, it can be treated as a post.(But there is no need to.) (But I would like not to change its url in cause of this).

That means: How to make:

  • one special blog entry being found at /blog/ (or at least one special markdown file)
  • and the normal list page from /blog/ being found at /blog/archive/

I tried to do this with [permalinks] in config.toml, but I didn’t get trough this.

Content here can be created at content/blog/, but keep in mind that this will list according to a list.html template and not a single.html template.

You’ll have to create a special layout for the archive. For example, layouts/blog/archive.html and then in the front matter of content/blog/, put the following (this is YAML, not TOML):

layout: archive

I think you missunderstood what I want.

That’s not what I want to do. I want to have one post at this adress. I figured out how to do this: put url = "/blog/" in the meta information of that post. No problem here so far.

I would have to update that manually. That’s not what I want. I want a normal list page move to another adress as I did to the single post before. But here this doesn’t work.

In addition: when I create an file, the url-meta-information in the single post works no longer.

I want to move the content from to the adress /blog/archive without touching it physically.

Right. You can do that by having the content of your be that “special post.” As I mentioned, you will just need to create your list template for /blog/ so that it only pulls in the content of the file at content/blog/

No, you wouldn’t. You would do this in the template you create…as I mentioned…

Ok, you’re right and I just don’t understand what you want to tell me - I am kind of noob in Hugo. Do you have some link to a tutorial where these archive layouts are explained?

Here is how to add content and front matter to list pages (i.e., any of your pages…and don’t forget the underscore). This will also help you with your forum question regarding first and last:

For changing a type or layout in front matter, I would recommend reading the docs on types:

As far as where to put your new layouts, I think my comments above are a good start :smile: HTH.

Also, after you give this a shot, please post a link to your source with any questions and I’ll try and give you some more concrete feedback on how you can get this done. Rest assured, you can do what you’re trying to do with Hugo…

So… I have to create a list page - for that I need no .md-file. Right? For that list page I will create a layout, called /layout/blog/archive/. Within that layout I can simply access the normal list pages variables, such as .Data.Pages, which have all posts stored (but only the posts, nothing else!) . Having this variable, I can create a normal list layout. Right?

So, there is only one question left:
How do I make that archive page render as a list page? (And having access to the posts?)

This is obviously just scaffolding for the archive…

1. Create a file at content/blog/ with the following front matter:

title: Archive
date: 2017-05-26
description: Whatever description you want, assuming you are using `.Desription` for SEO/metadata/whatever.
type: archive
layout: archive

Whatever content you may or may not want to add to the page....

2. Create a layout at layouts/type/archive.html

{{ range where .Site.Pages "Type" "blog" }}
{{ end }}

That should hopefully get you started. Note that .Site.Pages also includes, which I did intentionally because you said you want that index page to be a “special post.” If you want to remove pages from the list, use .Site.RegularPages.