jbake-org / jbake

Java based open source static site/blog generator for developers & designers.
http://jbake.org
MIT License
1.12k stars 326 forks source link

Date: Is it modified_date or published_date? #750

Closed bmarwell closed 2 years ago

bmarwell commented 2 years ago

Hi,

the date field (metadata) is very ambigious.

Writing the date in adoc (one is undocumented)

For one, you can write it in two ways:

= Title
Author
<date>

or (undocumented):

= Title
:jbake-date: 2022-01-01

Ok, now I am trying to get things "right". For the sitemap, we have a field like this:

        <lastmod>${content.date?string("yyyy-MM-dd")}</lastmod>

Modification time

Now, date seems to be the last modification time. So far, so good. This will also make sense because the documentation states:

If you leave the date field out then the files last modified timestamp will be used instead.

Published time

Now, we could need the "first published time" as well. We can add it like so:

= Title
:jbake-published_date: 2019-01-01
:jbake-date: 2022-01-01

HTML Metadata use

Ok, now we have different headers for different types: Post and Page.

If the published_date is set, we could use it for:

    <meta property="article:published_time" content="${content.published_date?datetime?string.iso_s_u}"/>
    <meta name="publish_date" property="og:publish_date" content="${content.published_date?datetime?string.iso_s_u}"/>

Otherwise we would need to use content.date instead, because it should never be empty.

We could then define:

        <#if (content.date)??>
    <meta property="article:modification_time" content="${content.date?datetime?string.iso_s_u}"/>
        </#if>

Question: post.published_time?

So the question remains: is the default date field intended as "last updated" time or as "first published"? I ask because the latter makes sense to assume because of this sentence in the documentation:

status: published-date - providing content date is equal to or past current date content will be considered published and included in the published collections

I think it would consider a published_date field instead and only fall back to date when the first one does not exist.

jonbullock commented 2 years ago

The original intent was "last updated", which was content file specific. Knowing when publishing occurred was taken care of by published_date which was not content file specific.

Could you elaborate on what you're trying to achieve?

bmarwell commented 2 years ago

Hi @jonbullock,

I want to properly set those fields:

    <meta property="article:published_time" content="${content.published_date?datetime?string.iso_s_u}"/>
    <meta name="publish_date" property="og:publish_date" content="${content.published_date?datetime?string.iso_s_u}"/>
    <meta property="article:modification_time" content="${content.date?datetime?string.iso_s_u}"/>

If no explicit "published_date" is set, e.g. via :jbake-published_date:, then it could (should?) be auto-filled with date.

bmarwell commented 2 years ago

Ah, I now understand what I'm missing.

If jbake-date is the "last-modified-date", then I think I'm missing a "first-published-on-date".

jbake-published_date is the date when the last baking of everything took place. That's not useful for those meta tags, as they are content related.