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

Margin along sides of post moving to the right after adding section heading #737

Closed
SebPouliot opened this issue Oct 31, 2022 · 3 comments
Closed
Labels
question general questions - not an issue

Comments

@SebPouliot
Copy link

Describe the bug

I'm guessing this is related to issue #591.

When writing a blog post from a rmarkdown file with the introduction theme the margin shifts to the right after adding a section heading.

Reproduce

  • Create site using victoriadrake/hugo-theme-introduction as theme in blogdown in RStudio. Uncheck the options for yaml.
  • Go into /content/en/blog and open long_form-post.md. Save that file as a long_form-post-test.Rmd file in the same location.
  • Render site

Navigating into blog and then All Posts, you'll see two entries in 2017 for Long Form Writing and Quotes. In the one generated from the .Rmd file, you'll notice the margin shifting after the first section heading. This does not happen in the entry generated from the .md file.

Expected behavior

The blog entries from the .md and the .Rmd files should produce the same output.

Screenshot

Screenshot 2022-10-31 134907

Desktop

Windows 11
Edge Version 106.0.1370.52
Hugo 0.104.3
Latest blogdown version
Latest RStudio version

@yihui yihui added the question general questions - not an issue label Nov 2, 2022
@yihui
Copy link
Member

yihui commented Nov 2, 2022

This is a CSS question. It will be great if you could follow the issue guide to ask on other forums next time before trying Github issues.

Basically, the theme defined CSS rules for .section: https://github.com/victoriadrake/hugo-theme-introduction/blob/3c01130d0a33006665a5762f151af6016eb02fae/assets/vendor/bulma/sass/layout/section.sass#L6

Then if you render .Rmd to .html (the default behavior), Pandoc will wrap content in section divs, which means for this theme, the post body will be wrapped inside

<div class="section">
  <div class="section"></div>
</div>

The outer div is from the theme. The inner div is from Pandoc.

There are two ways to fix the problem. You can either define CSS rules to eliminate the padding for the inner div, e.g.,

.section .section {
  padding: 0;
}

or render Rmd posts to .md instead of .html. For the latter way, you also have two choices: either use the file extension .Rmarkdown (see https://bookdown.org/yihui/blogdown/output-format.html), or set the global option blogdown.method = "markdown" in .Rprofile if you want all Rmd posts to be rendered to .md (see https://bookdown.org/yihui/blogdown/global-options.html).

@SebPouliot
Copy link
Author

Thanks for the great answer. Yes, I'll ask on another forum first next time.

I got the problem solved by editing the .Rprofile file.

Thanks Yihui for your amazing work.

@yihui
Copy link
Member

yihui commented Nov 2, 2022

Good to know! Thanks for the confirmation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question general questions - not an issue
Projects
None yet
Development

No branches or pull requests

2 participants