vistad
March 23, 2025, 3:50pm
21
@chrillek , I do understand you - but I just don’t have a repository - I should have set one up, definitely, but still did not. I just keep some local backups.
And in this case this wouldn’t change anything: we are talking about the most simple model - this is the code I use.
The frontmatter:
---
currency: '₾'
params:
products:
price: 13900
---
and HTML:
{{ with .Params }}
{{ range .products }}
{{ .price }} in {{ $.Params.currency }}
{{ end }}
{{ end }}
I can’t make it work.
Can you? Send me the most simple working example!
Thanks!
Of course your code above fails. You are ranging over products
but in your front matter it is not an array.
This is a simple, working example:
git clone --single-branch -b hugo-forum-topic-54039 https://github.com/jmooring/hugo-testing hugo-forum-topic-54039
cd hugo-forum-topic-54039
hugo server
Then visit http://localhost:1313/example/ .
vistad
March 23, 2025, 4:09pm
23
Here is the frontmatter:
---
title: 'MERCEDES BENZ S 550'
date: 2024-12-25T20:45:19+04:00
draft: false
categories: 'vehicles'
expiryDate: '2025-05-10'
permalink: 'vehicles/vehicles250510t2045190'
params:
products:
- image: 'vehicles/vehicles250510T2045191.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
- image: 'vehicles/vehicles250510T2045192.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
- image: 'vehicles/vehicles250510T2045193.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
- image: 'vehicles/vehicles250510T2045194.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
- image: 'vehicles/vehicles250510T2045195.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
- image: 'vehicles/vehicles250510T2045196.jpg'
item: 'MERCEDES BENZ S 550'
description: |
ავტომანქანის რეალიზაციას ახდენს ავტოჰაბი, ავტომანქანების სანახავად გვეწვიეთ შემდეგ მისამართზე: ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 (ოლიმპიური ქალაქის მიმდებარედ) ავტოჰაბის (AUTOHUB) მეორადი ავტომობილების ბაზრობა. GOOGLE MAP link: https://goo.gl/maps/B73MbzjbT1e5hyPTA ყველა ავტომობილი ტექნიკურად შემოწმებულია.(იქოქება, დადის) Autohub მობ: +სამუშაო საათები ორშაბათი-პარასკევი 10:00-18:00, შაბათი 10:00-14:00
tags: 'cars'
price: 13900
mileage: 221512
tags: ['cars']
currency: '₾'
sellers: 'Autohub'
sellertype: 'business'
id: 3468990459
tel: '+995 595 52 10 17'
whatsapp: 'yes'
iban: 'GE90TB0000000103893082'
address: 'ქ. თბილისი, დიღომი, ბობ უოლშის ქუჩა, I შესახვევი #2 '
email: 'info@autohub.ge'
delivery: 'no-delivery'
options: 'features'
fee: 111
checksum: '483ed7573ee2'
---
It is array and it ranges very well - the only problem is I can’t access the currency sign at the top level from the range scope.
Did you try the example that I provided? It is what you asked for.
vistad
March 23, 2025, 4:25pm
25
@jmooring : Yes, thank you very much for the example, I tried it!
However in your frontmatter:
---
title: Example
params:
currency: '₾'
products:
- price: 13900
---
the currency: ‘₾’ is not at the top level - my question was about this situation:
---
currency: '₾'
params:
products:
price: 13900
---
But nevertheless you are right!
I’ve read that ‘currency’ is a custom parameter, and should have moved it under the ‘params:’
But this was my original situation and I became confused.
Sorry and thank you!
As @irkode already described, whether or not currency
is at the top level of your front matter is irrelevant. Modify the example I provided and try it yourself.
irkode
March 23, 2025, 7:17pm
28
as far as i think I provided a simple few step instruction in some post above.
repeatedly showing the range loop without context around and i think we all mentioned that many times wont do it.
keeping saying it does not work when it does for all but you without contex…clueless