I was initially confused about how to use summaries. The only example code I found in the docs was on the page for list nodes, but that uses `Render "summary"`, which is for views, not an article summary. I thought a little example here might clarify the issue for future users.
It allows to use `where` template function like SQL `where` clause.
For example,
{{ range where .Data.Pages "Type" "!=" "post" }}
{{ .Content }}
{{ end }}
Now these operators are implemented:
=, ==, eq, !=, <>, ne, >=, ge, >, gt, <=, le, <, lt, in, not in
It also fixes `TestWhere` more readable
'where' template function used to accept only each element's struct
field name, method name and map key name as its second argument. This
extends it to accept dot chaining key like 'Params.foo.bar' as the
argument. It evaluates sub elements of each array elements and checks it
matches the third argument value.
Typical use case would be for filtering Pages by user defined front
matter value. For example, to filter pages which have 'Params.foo.bar'
and its value is 'baz', it is used like
{{ range where .Data.Pages "Params.foo.bar" "baz" }}
{{ .Content }}
{{ end }}
It ignores all leading and trailing dots so it can also be used with
".Params.foo.bar"
- Rejigged the weight of the extras/ content for the new crossreferences
page.
- Used the new {{</*…*/>}} format for documenting highlighting and to
prevent a warning about the missing `fig` shortcode.
- Correct some typos
- Add backticks and commas where necessary
- Use fenced code blocks specifying "bash" as the language
to avoid weird highlighting
- Place commas outside of quotation marks surroundingn codes
to avoid possible confusion
- Suggest users to use the discussion forum rather than the
mailing list
The whole article should maybe be rewriten to have a better content flow (maybe adding a table of content), to introduce both possible strategies. But at least, the technical steps are there!
This small function feels important enough to maybe deserve more than these three lines, but this will have to do for now.
This assumes that #652 gets merged.
This commit contains a restructuring and partial rewrite of the shortcode handling.
Prior to this commit rendering of the page content was mingled with handling of the shortcodes. This led to several oddities.
The new flow is:
1. Shortcodes are extracted from page and replaced with placeholders.
2. Shortcodes are processed and rendered
3. Page is processed
4. The placeholders are replaced with the rendered shortcodes
The handling of summaries is also made simpler by this.
This commit also introduces some other chenges:
1. distinction between shortcodes that need further processing and those who do not:
* `{{< >}}`: Typically raw HTML. Will not be processed.
* `{{% %}}`: Will be processed by the page's markup engine (Markdown or (infuture) Asciidoctor)
The above also involves a new shortcode-parser, with lexical scanning inspired by Rob Pike's talk called "Lexical Scanning in Go",
which should be easier to understand, give better error messages and perform better.
2. If you want to exclude a shortcode from being processed (for documentation etc.), the inner part of the shorcode must be commented out, i.e. `{{%/* movie 47238zzb */%}}`. See the updated shortcode section in the documentation for further examples.
The new parser supports nested shortcodes. This isn't new, but has two related design choices worth mentioning:
* The shortcodes will be rendered individually, so If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, one will be passed through the page's markdown processor, the other not.
* To avoid potential costly overhead of always looking far ahead for a possible closing tag, this implementation looks at the template itself, and is branded as a container with inner content if it contains a reference to `.Inner`
Fixes#565Fixes#480Fixes#461
And probably some others.
Update heading levels to confirm to the other tutorials. Create a similar front-matter using YAML, since I couldn't figure out how to get the menu:main:parent working as TOML.
`GroupBy` is modified to allow it to receive a method name argument for
example `Type` as its first argument. It is only allowed to call with
a method which takes no arguments and returns a result or a pair of
a result and an error.
The functions discussed at #443 are also added
- `ByPublishDate`: Order contents by `PublishDate` front matter variable
- `GroupByPublishDate(format, order)`: Group contents by `PublishDate`
front matter variable formatted in string like `GroupByDate`
- `GroupByParam(key, order)`: Group contents by `Param` front matter
variable specified by `key` argument
- `GroupByParamDate(key, format, order)`: Group contents by `Param`
front matter variable specified by `key` argument and formatted in
string like `GroupByDate`. It's effective against `time.Time` type
front matter variable
- Add backticks and commas where necessary
- Remove some trailing whitespace
- Add front matter example in TOML
- Fix typo in one of the tags in Showcase
- Add 多说 (Duoshuo) as an alternative to Disqus
- Use internal links (i.e. without gohugo.io) where possible
- Use a colon to set off an example
- Change "it's" to "its" where appropriate
- Use typographical (i.e. curly) apostrophe on the front page
where appropriate
- Capitalize "Github" as "GitHub"
The use of <!--more--> to set the breakpoint for the generated page summary is mentioned in a release note, but not in the doc itself.
Very useful - and it leaves the formatting in place.
- The config file can provide FootnoteAnchorPrefix, which will be used
by blackfriday when rendering to HTML. A value of `q:` has the effect
of making the anchor for a footnote `[^footie]` be `fn:q:footie`. The
default is `""`.
- The config file can provide FootnoteReturnLinkContents, which will be
used by blackfriday when rendering to HTML. A value of `^` has the
effect of making the return link be `^` instead of `[return]`.
updated installation page of documentation, and changed "Download" button on index.html to scroll to bottom where multiple installation options are featured
getting the scrolldown to work required removing the fixed positioning on #action and on the footer
Emphasizing to people (like me) who aren't familiar with Go that just because something's not mentioned in the Hugo docs doesn't mean it's not possible
Among the various changes, most instances of
{{ template "partials/FILE.html" . }}
were changed to
{{ partial "FILE.html" . }}
Also, in main.go, change "2013" to "2013-14".
The "@import url()" statement for loading Lato from Google Fonts
was ignored because "@import are not allowed after any valid statement
other than @charset and @import" according to the W3C CSS Validator.
Also remove the line for importing line-icons.css which no longer
exists.
I noticed that config file changes do not work with Live Reload feature. This may be "fixed" in future but for now adding a note might avoid confusion.
It took me a long time to realize that /layouts/TYPE or SECTION/LAYOUT.html was supposed to be a single URL and not two urls (/layouts/TYPE) or (SECTION/LAYOUT.html) ... putting in the hyphens I think makes it much more clear it's all one URL, and only the middle part is an either-or.
Two issues are addressed with this commit:
1. Some <pre> tags were inheriting the "Serif" font on Linux, causing
"code"-ish stuff to appear with proportional-width font instead of
monospaced-width font.
2. Font stack with "Helvetica Neue" ... has been changed to default to
sans-serif instead of "Serif", this produces a more consistent and
friendlier look on Windows in particular.
- previously it was ambiguous between the actual Step 1 and the "step 1" of the steps *within* Step 2 ("Clone into the hugo repository")
- also fixed a typo I guess
A photography-oriented blog using Foundation 5 by Zurb. Responsive
layout with padded large and full-width small views. A sample
"polaroid" shortcode is included for image showcases, as is a
"header" image directive in the frontmatter.
Be able to inhibit AbsURL canonicalization of content, on a site
configuration basis. Advantages of being able to inhibit this include
making it easier to rendering on other hostnames, and being able to
include resources on http or https depending on how this page was
retrieved, avoiding mixed-mode client complaints without adding latency
for plain http.
I've added the website for the makerspace I founded into the hall of fame list as an example of what you can do with Hugo.
It's a work in progress (like everything) but should show people another example of using Hugo in the real world.
Hugo has made it much easier to update our website content without needing to use bloated or expensive tools.
Thanks!
* extras/permalinks.md added, weighted to third in the extras menu
* examples added to layout/go-templates.md, using `.Site.Params`
* mention `.Site.Params` in layout/variables.md
* update meta/release-notes.md to mention `first` and the permalinks
* update overview/configuration.md to use reserved-for-documentation
domains and with another example, nudging towards permalinks and site
parameters, with three different data-types shown for the latter
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
The render code path would use a fallback if there was an exception.
This change instead relies on explicit declaration of the layout to use
and includes a check to see if the layout indeed exists before
attempting to render it.
The pflag package used in hugo has to use the "=" sign
for double dash options such as --source. Thus the original
example `--source ~/mysite` is already incorrect. Adding
the = sign though woul not fix things in this case, since
`--source=~/mysite` does not get resolved to /home/username/mysite,
but looks for the ./~/mysite directory within the current directory.
To resolve this, either the directory name has to be changed in
the docs not to use the "~" sign, or have to change to use the
single dash version of the command line flag. The latter seems
to be more in line with the rest of the example.
Leaving `--watch` as a double dash option to minimize the change,
though it could be either way, since the follow up example uses
the single dash version of both.