Skip to content

Add local dev carto API workflow and docs - #172

Open
wagnerlmichael wants to merge 2 commits into
mainfrom
171-test-local-dev-carto-key-workflow
Open

wagnerlmichael wants to merge 2 commits into
mainfrom
171-test-local-dev-carto-key-workflow

Conversation

@wagnerlmichael

@wagnerlmichael wagnerlmichael commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Takes care of #171.

I signed up for my own API key and it worked for me locally.

@wagnerlmichael wagnerlmichael linked an issue Oct 9, 2026 that may be closed by this pull request
Comment thread README.md
so that the [development server](#running-a-development-server) can render
them. Without it, the script builds static HTML into `hugo/public/` and then
deletes the Markdown, so the reports won't be available from `hugo serve`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an explanation here about how when testing locally the hugo serve just needs the markdown, not the html flow through actions

Comment thread hugo/layouts/report.html
{{/* Carto basemap API key. Deployed builds use a key restricted to the
prod and staging hosts; `hugo serve` reads a local key from the
HUGO_CARTO_KEY env var (see README) */}}
const cartoKey = {{ cond hugo.IsServer (getenv "HUGO_CARTO_KEY") "cb1_45dr_1_d676f2f54005676a45bee03c" }};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wagnerlmichael
wagnerlmichael marked this pull request as ready for review October 9, 2026 18:26

@jeancochrane jeancochrane left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tying up this loose end!

Comment thread README.md Outdated
Comment thread README.md
export HUGO_CARTO_KEY=<your_key>
```

4. Run `hugo serve` and open a report that has a map. The tiles should load

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Thought, non-blocking] I think users will probably need to generate a report before they can run hugo serve and see maps, right? Not sure if that should be documented here, but I temporarily forgot about that step while testing.

Comment thread README.md
Comment on lines +49 to +54
3. Add the key to your shell profile (e.g. `~/.bashrc`), then restart your
shell:

```
export HUGO_CARTO_KEY=<your_key>
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Thought, non-blocking] I think this is a fine approach, but I keep my dotfiles under version control in a public repo, so I didn't want to stash this API key in my bashrc. Another alternative is just to store it in a password manager and then set the env var like so whenever you need to generate reports:

HUGO_CARTO_KEY=<my_key> python3 scripts/generate_homeval/generate_homeval.py ...

I don't necessarily think we need to document this flow, just flagging it in case it's interesting!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the env method should be left for the user to approach on their own? Or do you think we should have some sort of instruction for it here? I'm not sure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your instructions are fine!

Co-authored-by: Jean Cochrane <jeancochrane@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test local dev carto key workflow

2 participants