Add titles by using YML data

Hi!, I’m newbie using this.

My question is about page titles, I’m trying to use a unique file to put titles into pages, I mean

I want to use a data.yml file which includes something like this:

index:
    title: 'Some title'

other_section:
    title: 'Other title'

And use to render a title for every single page. It’s that possible?

I know that the normal way is adding the title at the top of the partial. But I want it more organised in a single file.

Thanks to all :wink:

It is possible but, are you generating those pages dynamically (there are no files for them)? If not, it doesn’t really make much sense to do that (or I’m missing something). Adding the page’s title, and any other data you’d like to include, in its frontmatter (check out https://middlemanapp.com/basics/frontmatter/) is a cleaner solution.

If you still want to do it that way, then you should follow https://middlemanapp.com/advanced/data_files/ guidelines, and figure out a way to retrieve the specific data for each page.

1 Like

Hi @jpmelguizo you’re right, I have readed about Frontmatter and I’m actually using it, but by the way it has no sense to use a data.yml because all my views are static. Thanks for the info :wink: