Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org subtree as Markdown Headline 1 #712

Open
geometryolife opened this issue May 15, 2023 · 6 comments
Open

Org subtree as Markdown Headline 1 #712

geometryolife opened this issue May 15, 2023 · 6 comments
Labels
not a bug This is the expected behavior, not a bug

Comments

@geometryolife
Copy link

Actual Behavior

---
title: "My first docs"
draft: true
---

## H1 {#h1}


### S1 {#s1}


### S2 {#s2}


## H2 {#h2}


### Sub {#sub}


## H3 {#h3}

Expected Behavior

---
draft: true
---

# My first docs

## H1 {#h1}


### S1 {#s1}


### S2 {#s2}


## H2 {#h2}


### Sub {#sub}


## H3 {#h3}

How to Reproduce the Issue

Example Org File

#+hugo_base_dir: .
#+hugo_section: docs
#+hugo_front_matter_format: yaml

* Aptos Move by Example

** TODO My first docs
:PROPERTIES:
:EXPORT_FILE_NAME: my-first-docs
:END:
*** H1
**** S1
**** S2

*** H2

**** Sub

*** H3

Generated Markdown File or Error

Ox-Hugo Debug Information

Debug Info
@kaushalmodi
Copy link
Owner

Hello, this is the expected behavior.

Markdown doesn't have a "title" syntax. So the Org mode title gets converted to Hugo markdown's title front-matter.

The Hugo template usually renders the title front-matter as h1 HTML tag. So the headings of the post are exported as ## in Markdown so that they get rendered to h2 in HTML.

@kaushalmodi kaushalmodi added the not a bug This is the expected behavior, not a bug label May 15, 2023
@kaushalmodi
Copy link
Owner

Here's a workaround.. but I really really do NOT recommend going this route.

#+hugo_base_dir: .
#+hugo_section: docs
#+hugo_front_matter_format: yaml
#+hugo_level_offset: 0
#+options: author:nil

* Aptos Move by Example

** TODO Dummy title -- Make sure you don't render the title front-matter in Hugo templates
:PROPERTIES:
:EXPORT_FILE_NAME: my-first-docs
:END:
*** My first docs
**** H1
***** S1
***** S2
**** H2
***** Sub
**** H3

Markdown export:

---
title: "Dummy title – Make sure you don't render the title front-matter in Hugo templates"
draft: true
---

# My first docs {#my-first-docs}


## H1 {#h1}


### S1 {#s1}


### S2 {#s2}


## H2 {#h2}


### Sub {#sub}


## H3 {#h3}

@geometryolife
Copy link
Author

Thank you @kaushalmodi
Thanks for your answer, I saw this method from #375, I also think this method is not very good.
I'd like to request this feature, and it would be nice to add a property to ox-hugo to do this.
In fact, Markdown Docs of many document frameworks will use # as the Headline 1 of a file, such as Docusaurus, hugo-book etc.

@kaushalmodi
Copy link
Owner

In fact, Markdown Docs of many document frameworks will use # as the Headline 1 of a file, such as Docusaurus, hugo-book etc.

Thank you. I was not aware of that.

I'd like to request this feature, and it would be nice to add a property to ox-hugo to do this.

I am severely restricted on my time for this project as I still need to fix the GHA CI before I make any changes. I would believe that any Hugo project should respect the title in the title front-matter and render that as h1 tag. If this feature gets implemented in the future, it shouldn't need you to change any of your Org mode content.

@geometryolife
Copy link
Author

If this feature gets implemented in the future, it shouldn't need you to change any of your Org mode content.

Thanks, some frameworks treat docs and blog types differently, docs type documents use # as the title, and bolg type documents use title in front-matter as the title.

@kaushalmodi
Copy link
Owner

docs type documents use # as the title, and bolg type documents use title in front-matter as the title.

I hope it is easy to fix that inconsistency in the framework's Hugo template.

Pseudocode:

if (title != "") {
  Render title as h1
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug This is the expected behavior, not a bug
Projects
None yet
Development

No branches or pull requests

2 participants