Giter Site home page Giter Site logo

hugo-tufte's Introduction

This theme isn't maintained anymore. Please use https://github.com/loikein/hugo-tufte, note that it is has been modified quite a bit but at least it is up to date.

Tufte Hugo Theme

Contributor Covenant build github pages

Hugo-Tufte is a minimalist blog-like theme for the static site generator Hugo that attempts to be a faithful implementation of the Tufte-css project. It supports mathematical typesetting via katex or MathJax. By utilizing copious partial templates the theme is largely customizable.

This is a fork of the original hugo-tufte.

Quickstart

Prerequisite: Hugo Extended

You'll need to install Hugo Extended for this theme to test it locally, since this theme uses SCSS.

  • On Windows:
    • Using Chocolatey:
      choco install hugo-extended # remember, you might need admin privs

For a new site

# this code is shell-agnostic, and should work in cmd, powershell, bash, zsh....
hugo new site <your-site-name> # create your new site with hugo in your pwd
cd <your-site-name>\themes\    # cd into the themes directory
git clone <this-git-repo>      # HTTPS link @ the top of the page if you've never done this before

Add theme = 'hugo-tufte' to your config.toml to let your site know to actually use this theme, specifically.

Then run hugo server -D and open up localhost:1313/ or wherever it says in Firefox.

Features

Math

Katex or MathJax renders LaTeX written inside of markdown files. LaTeX can be written more or less as normal. Some examples:

  • This $\frac{1}{2}$ will be rendered inline.
  • A simple displayed equation: $$f(x, y) := e^{x^2 - y^2}.$$

There currently seems to be some weirdness with other environments, such as the aligned environment (align* is not supported by katex). These environments will render provided they are wrapped in <p> tags and blank lines. The snippet below should render correctly.

Let $G$ be a finite group with exponent $2$.  Then every element is
an involution, hence for any $x$, $y$ in $G$ we have:

<p>
\begin{aligned}
  e &= (xy)^2  \\
  &=xyxy \implies \\
  y^{-1} &= xyx \implies \\
  y^{-1}x^{-1} &= xy,
\end{aligned}
</p>

establishing that $G$ is abelian.

Site Parameters

The site specific parameters that this theme recognizes are:

  • subtitle string: This is displayed under the main title.
  • showPoweredBy boolean: if true, display a shoutout to Hugo and this theme.
  • copyrightHolder string: Inserts the value in the default copyright notice.
  • copyright string: Custom copyright notice.
  • math boolean: Site wide kill switch for Latex support
  • katex boolean: if "katex" is set to true katex will be used to render LaTex, if not MathJax will be used instead. (Set to true by default)
  • codeBlocksDark boolean: if true, code blocks will use a dark theme.

Socials

You can add links to your social media profile by using thoses parameters:

  • github: string
  • gitlab: string
  • twitter: string
  • patreon: string
  • youtube: string
  • medium: string
  • reddit: string
  • stackoverflow: string
  • instagram: string
  • mastodon: string
  • orcid: string
  • google_scholar: string

Please see exampleSite/config.toml to see the full implementation with exemples.

Page Parameters

  • hideDate boolean: if true, do not display a page date. When meta is set to true, hideDate takes greater precedence.
  • hideReadTime boolean: if true, do not display the page's reading time estimate. When meta is set to true, hideReadTime takes greater precedence.
  • math boolean: if true, try to render the page's LaTeX code using MatheJax.
  • meta boolean: if true, display page metadata such as author, date, categories provided these page parameters exist and are not overridden. Content in the /post directory, (i.e., pages of type "post") ignore this parameter.
  • toc boolean: if true, display the table of contents for the page.

Shortcodes

This theme provides the following shortcodes in an attempt to completely support all the features present in the Tufte-css project.

  • blockquote

    • Description: Wrap text in a blockquote and insert optional cite or footer metadata.
    • Usage: Accepts the named parameters cite and footer.
    • Example:
    {{< blockquote cite="www.shawnohare.com" footer="Shawn" >}}
      There is nothing more beautiful than an elegant mathematical proof.
    {{< /blockquote >}}
  • div

    • Description: This shortcode is provided as a work-around for wrapping complex blocks of markdown in div tags. The wrapped text can include other shortcodes
    • Usage: Identical to the section shortcode. Accepts the style parameters class and id. If only the positional argument "end" is passed, a closing tag will be inserted.
    • Example: {{< div class="my-class" >}} inserts a <div class="my-class"> tag, while {{<div "end" >}} inserts the closing </div> tag.
  • epigraph

    • Description: Create an epigraph with the wrapped text.
    • Usage: To include a footer with source attribution, pass in the optional named parameters pre, cite, post, link. These parameters make no styling assumptions, so spacing is important. A more compactly styled epigraph will be used if the type parameter is set to compact.
    • Example:
    {{< epigraph pre="Author Writer, " cite="Math is Fun" link='https://www.google.com' >}}
    This is an example of an epigraph with some math
    $ \mathbb N \subseteq \mathbb R $
    to start the beginning of a section.
    {{< /epigraph >}}
  • marginnote

    • Description: Wrap text to produce a numberless margin note.
    • Usage: {{< marginnote >}}...{{< /marginnote >}}
    • Example:
    {{< marginnote >}}Some marginnote{{< /marginnote>}}
  • section

    • Description: This shortcode is provided as a work-around for wrapping complex blocks of markdown in section tags. The wrapped text can include other shortcodes
    • Usage: Accepts the style parameters class and id. If only the positional argument "end" is passed, a closing tag will be inserted.
    • Example: {{< section class="my-class" >}} inserts a <section class="my-class"> tag, while {{<section "end" >}} inserts the closing </section> tag.
  • sidenote

    • Description: Wrap text to produce an automatically numbered sidenote.
    • Usage: identical to marginnote {{< sidenote >}}...{{< /sidenote >}}
    • Example:
    {{< sidenote >}}Some sidenote{{< /sidenote >}}

hugo-tufte's People

Contributors

cwimmer avatar dwarkeshsp avatar erik-j-d avatar fangyi-zhou avatar hiandrewquinn avatar jeremyf avatar joshuata avatar machawk1 avatar shawnohare avatar sje30 avatar slashformotion avatar tjdcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hugo-tufte's Issues

Not sure if this is a bug or not: Second level bullet lists have short lines

I believe that this is a bug, but if it is a style choice that is part of the Tufte system, I apologize. I cannot find anything that indicates that this is a stylistic choice.

What version of Go are you using ($ hugo version)?

hugo v0.90.1-48907889+extended windows/amd64 BuildDate=2021-12-10T10:56:41Z VendorInfo=gohugoio

Installed with chocolatey for Windows.

What operating system and processor architecture are you using?

Windows 10 Home, Intel i5. I see similar results with another Windows computer running 10 Pro.

What did you do?

I created a bulleted list with the usual hugo/markdown procedure. Here is example code that reproduces the error on several Tufte pages where I inserted it:

Here is a bullet list:

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- Arcu felis bibendum ut tristique et. Volutpat odio facilisis mauris sit amet massa.
- Sed id semper risus in hendrerit gravida rutrum.
  - Risus pretium quam vulputate dignissim suspendisse in est ante. Bibendum neque egestas congue quisque egestas diam in arcu.
  - Nulla porttitor massa id neque aliquam. Laoreet non curabitur gravida arcu ac tortor dignissim convallis.
- Sit amet consectetur adipiscing elit.

The problematic behavior is in the indented items on the list.

What did you expect to see?

I expected to see all of the lines extend to the same right-hand boundary for word-wrapping. That is, I expected the indented lines to go to the same right boundary as the un-indented items.

What did you see instead?

The second-level (indented) bullets are on lines that are about half the length of the first-level lines.

Is this the normal behavior for the Tufte style? I could not find examples showing it as clearly intentional nor did I see it elsewhere.

Here is what it looks like for me:

image

Optional (best if completed)

To Reproduce
Steps to reproduce the behavior:

  1. On any page add the code snippet above. (I tested in on the example site pages with the theme; specifically by adding the code to the about page and to one of the blog entry type pages.)
  2. Render the page (hugo serve -D).
  3. Look at the served page.

Markdown in marginnote

Hi, I'm not sure if this is a bug or a feature request, but I was surprised that marginnotes don't take markdown as input. The input is litterally copied into the HTML, so HTML is accepted.

Is this a stringent limitation of the theme?

Best regards,
Vic

Mobile view of Tufte theme appears to hide one picture (on demo site)

What version of Hugo are you using ($ hugo version)?

hugo v0.90.1-48907889+extended windows/amd64 BuildDate=2021-12-10T10:56:41Z VendorInfo=gohugoio (for Windows part)

What operating system and processor architecture are you using?

Intel chip, windows 10 for the regular browser view and the simulated iPhone views. Samsung Galaxy S10e for the real mobile views.

What did you do?

I built the test website and viewed it in Chrome as an "iPhone 12 Pro" form factor (via the developer tools). I did this same thing using the demo website ( https://slashformotion.github.io/hugo-tufte/post/tufte-features/ ) and got the same result. Results replicated on my Samsung S10e phone (included in pictures below).

What did you expect to see?

I expected to see the mobile view of the page, with all figures working. However, the "plus sign" for opening and closing figures does not work correctly (for ONE of the figures, the rest are ok).

This is the page viewed in a browser under windows 10:

hugo-tufte-working-page-01

What did you see instead?

Specifically, the picture of the Rhino does not appear and pressing either of the "plus signs" near it just open the caption for a different figure. Nothing I do makes the rhino figure appear. I believe that the lower plus sign in the figure shown below is supposed to reveal and hide the rhino figure.

Here are two mobile views (Samsung), with various states shown. The two plus signs (both) only control the caption on the visible figure. The rhino does not appear, even if the view is moved to look at the whitespace on the right:

With caption:
hugo-tufte-on-phone-w-caption-arrows

Without caption:
hugo-tufte-on-phone-w-o-caption

If I can provide any more information, please let me know.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://slashformotion.github.io/hugo-tufte/post/tufte-features/
  2. Open on a mobile device.
  3. Compare with the full sized web page in a desktop or laptop browser.
  4. Try to find the rhino.

'highlight' class broken on mobile

On mobile, code highlight blocks become too narrow, they think they still need to leave room for margin notes:
highlight bug

I was able to fix it locally by adding the following to code-highlight.scss:

@media screen and (max-width: 760px) {
    .highlight {
        width: 90%;
    }
}

I'd send a PR but I'm not sure that's an idiomatic way to do this.

I'm on hugo v0.89.4+extended linux/amd64 BuildDate=unknown and I pulled the latest hugo-tufte too.

Two deprecation warnings for _normalize-mixin.scss

What version of Go are you using ($ hugo version)?

v0.80.0/extended

What operating system and processor architecture are you using?

Linux, Fedora 33, x86-64

What did you do?

Running hugo server with a fresh clone of hugo-tufte in an empty project

What did you expect to see?

No errors or deprecation warnings.

What did you see instead?

Two deprecation warnings for the _normalize-mixin.scss file.

DEPRECATION WARNING on line 16 of /path/to/site/themes/hugo-tufte/assets/scss/vendor/normalize/_normalize-mixin.scss:
!global assignments won't be able to declare new variables in future versions.
Consider adding `$-normalize-include: null` at the top level.

DEPRECATION WARNING on line 16 of /path/to/site/themes/hugo-tufte/assets/scss/vendor/normalize/_normalize-mixin.scss:
!global assignments won't be able to declare new variables in future versions.
Consider adding `$-normalize-exclude: null` at the top level.

Adding $-normalize-exclude: null and $-normalize-include: null to the top of _normalize-mixin.scss removes the deprecation error but I'm as I'm not familiar with SCSS, I'm not sure if this has unintended consequences elsewhere in the project.

If adding these lines is not an issue, it would be good to add them to the repo and remove some of the "deprecation" noise for users. I can open an MR if needed.

Hello, please check the issue below !

Hello, I mentioned you here because you forked or starred this theme.
I just have a few questions and your answers would really help me improve Hugo-Tufte.

What features would you like to be supported on this theme ?
Did you see some bugs or issues ?
If you were in charge what would you do to improve it ?

@eigenbeam @Uzoamaka126 @korymath @sickcallfuu @chugiau @chugiau @livrth @kir0ul @michaelmcdonald @zhangsherry @noahdiewald @harper357 @aj-kueterman @bemilton @nehbit @hieu6 @dwarkeshsp @bwklein @zsoltika @zohaad

inline katex is broken

Improve katex support with

renderMathInElement(
    document.body,
    {
        delimiters: [
            { left: "$$", right: "$$", display: true },
            { left: "\\[", right: "\\]", display: true },
            { left: "$", right: "$", display: false },
            { left: "\\(", right: "\\)", display: false }
        ],
        displayMode: true
    }
);

[discussing Obsidian support]

I think you've done a great job, thank you so much for sticking with it! A nice to have would be to include a module for [[wikilinks]] being translated to the relative link shortcode. Would be nice to use Obsidian.md as a cms along with this theme.

Originally posted by @hieu6 in #35 (comment)

Well the problem is the md->html converter Hugo uses, it seems that it doesn't support wikilinks but there is several projects to convert wiki links to normal markdown syntax in obsidian

Widen text for mobile

Is there any way to widen the text max-width for mobile? Unlike the actual Tufte CSS example, this template seems to become awfully narrow on mobile. See image below of this template.

example

If the website going to autohide the margin notes on narrow screens anyways, why not have the text use the full width on the screen? I'm not sure what part of the CSS controls this width, but I'll keep looking. In the meantime, if you happen to know where it is and can change it, that would be greatly appreciated.

No rush or pressure! I appreciate that you are maintaining this template and I have no expectation for you to fulfill special requests like these.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.