quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.89k stars 320 forks source link

Title and date can be duplicated in hugo output #795

Closed linogaliana closed 2 years ago

linogaliana commented 2 years ago

When using hugo format, I experienced that title and date will be duplicated in output. They will be present two times: once in the YAML but also in the document.

For instance, the example in the document

---
title: Hello, Quarto
date: "2012-04-06"
categories: 
  - Matplotlib
  - Coordinates
format: hugo
jupyter: python3
---

## Polar Axis

For a demonstration of a line plot on a polar axis, see @fig-polar.

```{python}
#| label: fig-polar
#| fig-cap: "A line plot on a polar axis"

import numpy as np
import matplotlib.pyplot as plt

r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

will lead to the following .md when using quarto render --to hugo:

---
title: Hello, Quarto
date: "2012-04-06"
categories: 
  - Matplotlib
  - Coordinates
format: hugo
jupyter: python3
---

Hello, Quarto
================
2012-04-06

## Polar Axis
...

which does not mix well with wowchemy/academic themes (see my personal project https://62726a7214f35700b4efbea7--linogaliana-teaching.netlify.app/rappelsclasses/ : title and date are duplicated)

If possible, the best option would be to avoid creating the

title
================
date

section.

quarto version

I used version 0.9.345

cderv commented 2 years ago

We have this because for format: hugo, we are using a special template https://github.com/quarto-dev/quarto-cli/blob/2b4efc1c83ebe7affa1b0acbd21bdc1cf0447c96/src/resources/pandoc/templates/default.markdown?plain=1#L1-L10 which will output title, date and author.

@jjallaire when you added this template in f9ee6765fe22394819bf95c58863496dcecfa3b7, what it suppose to cover format: hugo ? I am not sure title, date and author are desired in a Hugo markdown format.

jjallaire commented 2 years ago

No, that should not have targeted hugo (or any markdown generation where keep-yaml is in play). Fixed here: https://github.com/quarto-dev/quarto-cli/commit/29ffff9cd35eb433414e91e12b28e8ad9bf3ed04

cderv commented 2 years ago

Oh I see ! I did not spotted this part with keep-yaml. Thanks!

linogaliana commented 2 years ago

Yes this solved the issue, thanks (tested locally)